Chinaunix首页 | 论坛 | 博客
  • 博客访问: 463767
  • 博文数量: 100
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 955
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-21 09:30
文章分类

全部博文(100)

文章存档

2017年(1)

2016年(16)

2015年(83)

我的朋友

分类: 嵌入式

2015-09-27 16:50:19




点击(此处)折叠或打开

  1. /*
  2.      * dmc0 initialization at single type
  3.      */
  4.     ldr    r0, =0xf0000000

  5.     ldr    r1, =0x00101000                /* phycontrol0 dll parameter setting */
  6.     str    r1, [r0, #0x18]

  7.     ldr    r1, =0x00000086                /* phycontrol1 dll parameter setting */
  8.     str    r1, [r0, #0x1c]

  9.     ldr    r1, =0x00101002                /* phycontrol0 dll on */
  10.     str    r1, [r0, #0x18]

  11.     ldr    r1, =0x00101003                /* phycontrol0 dll start */
  12.     str    r1, [r0, #0x18]

  13. dmc0_lock:
  14.     ldr    r1, [r0, #0x40]                /* load phystatus register value */
  15.     and    r2, r1, #0x7
  16.     cmp    r2, #0x7                    /* loop until dll is locked */
  17.     bne    dmc0_lock

  18.     and    r1, #0x3fc0
  19.     mov    r2, r1, LSL #18
  20.     orr    r2, r2, #0x100000
  21.     orr    r2 ,r2, #0x1000

  22.     orr    r1, r2, #0x3                /* force value locking */
  23.     str    r1, [r0, #0x18]

  24.     /* setting ddr2 */
  25.     ldr    r1, =0x0FFF2010                /* concontrol auto refresh off */
  26.     str    r1, [r0, #0x00]

  27.     ldr    r1, =0x00212400                /* memcontrol bl=4, 2 chip, ddr2 type, dynamic self refresh, force precharge, dynamic power down off */
  28.     str    r1, [r0, #0x04]

  29.     ldr    r1, =DMC0_MEMCONFIG_0        /* memconfig0 256MB config, 8 banks, mapping method[12:15] 0:linear, 1:linterleaved, 2:mixed */
  30.     str    r1, [r0, #0x08]

  31.     ldr    r1, =DMC0_MEMCONFIG_1        /* memconfig1 */
  32.     str    r1, [r0, #0x0c]

  33.     ldr    r1, =0xFF000000                /* prech config */
  34.     str    r1, [r0, #0x14]

  35.     ldr    r1, =DMC0_TIMINGA_REF        /* timing aref */
  36.     str    r1, [r0, #0x30]

  37.     ldr    r1, =DMC0_TIMING_ROW        /* timingRow */
  38.     str    r1, [r0, #0x34]

  39.     ldr    r1, =DMC0_TIMING_DATA        /* timing data CL=3 */
  40.     str    r1, [r0, #0x38]

  41.     ldr    r1, =DMC0_TIMING_PWR        /* timing power */
  42.     str    r1, [r0, #0x3c]

  43.     ldr    r1, =0x07000000                /* chip0 deselect */
  44.     str    r1, [r0, #0x10]

  45.     ldr    r1, =0x01000000                /* chip0 pall */
  46.     str    r1, [r0, #0x10]

  47.     ldr    r1, =0x00020000                /* chip0 emrs2 */
  48.     str    r1, [r0, #0x10]

  49.     ldr    r1, =0x00030000                /* chip0 emrs3 */
  50.     str    r1, [r0, #0x10]

  51.     ldr    r1, =0x00010400                /* chip0 emrs1 (mem dll on, dqs disable) */
  52.     str    r1, [r0, #0x10]

  53.     ldr    r1, =0x00000542                /* chip0 mrs (mem dll reset) cl=4, bl=4 */
  54.     str    r1, [r0, #0x10]

  55.     ldr    r1, =0x01000000                /* chip0 pall */
  56.     str    r1, [r0, #0x10]

  57.     ldr    r1, =0x05000000                /* chip0 refa */
  58.     str    r1, [r0, #0x10]

  59.     ldr    r1, =0x05000000                /* chip0 refa */
  60.     str    r1, [r0, #0x10]

  61.     ldr    r1, =0x00000442                /* chip0 mrs (mem dll unreset) */
  62.     str    r1, [r0, #0x10]

  63.     ldr    r1, =0x00010780                /* chip0 emrs1 (ocd default) */
  64.     str    r1, [r0, #0x10]

  65.     ldr    r1, =0x00010400                /* chip0 emrs1 (ocd exit) */
  66.     str    r1, [r0, #0x10]

  67.     ldr    r1, =0x07100000                /* chip1 deselect */
  68.     str    r1, [r0, #0x10]

  69.     ldr    r1, =0x01100000                /* chip1 pall */
  70.     str    r1, [r0, #0x10]

  71.     ldr    r1, =0x00120000                /* chip1 emrs2 */
  72.     str    r1, [r0, #0x10]

  73.     ldr    r1, =0x00130000                /* chip1 emrs3 */
  74.     str    r1, [r0, #0x10]

  75.     ldr    r1, =0x00110400                /* chip1 emrs1 (mem dll on, dqs disable) */
  76.     str    r1, [r0, #0x10]

  77.     ldr    r1, =0x00100542                /* chip1 mrs (mem dll reset) cl=4, bl=4 */
  78.     str    r1, [r0, #0x10]

  79.     ldr    r1, =0x01100000                /* chip1 pall */
  80.     str    r1, [r0, #0x10]

  81.     ldr    r1, =0x05100000                /* chip1 refa */
  82.     str    r1, [r0, #0x10]

  83.     ldr    r1, =0x05100000                /* chip1 refa */
  84.     str    r1, [r0, #0x10]

  85.     ldr    r1, =0x00100442                /* chip1 mrs (mem dll unreset) */
  86.     str    r1, [r0, #0x10]

  87.     ldr    r1, =0x00110780                /* chip1 emrs1 (ocd default) */
  88.     str    r1, [r0, #0x10]

  89.     ldr    r1, =0x00110400                /* chip1 emrs1 (ocd exit) */
  90.     str    r1, [r0, #0x10]

  91.     ldr    r1, =0x0FF02030                /* concontrol auto refresh on */
  92.     str    r1, [r0, #0x00]

  93.     ldr    r1, =0xFFFF00FF                /* pwrdn config */
  94.     str    r1, [r0, #0x28]

  95.     ldr    r1, =0x00202400                /* memcontrol bl=4, 2 chip, ddr2 type, dynamic self refresh, force precharge, dynamic power down off */
  96.     str    r1, [r0, #0x04]

  97.     /*
  98.      * dmc1 initialization at single type
  99.      */
  100.     ldr    r0, =0xf1400000

  101.     ldr    r1, =0x00101000                /* phycontrol0 dll parameter setting */
  102.     str    r1, [r0, #0x18]

  103.     ldr    r1, =0x00000086                /* phycontrol1 dll parameter setting */
  104.     str    r1, [r0, #0x1c]

  105.     ldr    r1, =0x00101002                /* phycontrol0 dll on */
  106.     str    r1, [r0, #0x18]

  107.     ldr    r1, =0x00101003                /* phycontrol0 dll start */
  108.     str    r1, [r0, #0x18]

  109. dmc1_lock:
  110.     ldr    r1, [r0, #0x40]                /* load phystatus register value */
  111.     and    r2, r1, #0x7
  112.     cmp    r2, #0x7                    /* loop until dll is locked */
  113.     bne    dmc1_lock

  114.     and    r1, #0x3fc0
  115.     mov    r2, r1, LSL #18
  116.     orr    r2, r2, #0x100000
  117.     orr    r2 ,r2, #0x1000

  118.     orr    r1, r2, #0x3                /* force value locking */
  119.     str    r1, [r0, #0x18]

  120.     /* setting ddr2 */
  121.     ldr    r1, =0x0FFF2010                /* concontrol auto refresh off */
  122.     str    r1, [r0, #0x00]

  123.     ldr    r1, =0x00212400                /* memcontrol bl=(2)4, (1)2 chip, (2)32bit, ddr2 type=(4)DDR2, dynamic self refresh, force precharge, dynamic power down off */
  124.     str    r1, [r0, #0x04]                /*[22:20]=2,[19:16]=1(2 chip),*/

  125.     ldr    r1, =DMC1_MEMCONFIG_0        /* memconfig0 256MB config, 8 banks, mapping method[12:15] 0:linear, 1:linterleaved, 2:mixed */
  126.     str    r1, [r0, #0x08]

  127.     ldr    r1, =DMC1_MEMCONFIG_1        /* memconfig1 */
  128.     str    r1, [r0, #0x0c]

  129.     ldr    r1, =0xFF000000                /* prech config */
  130.     str    r1, [r0, #0x14]

  131.     ldr    r1, =DMC1_TIMINGA_REF        /* timing aref */
  132.     str    r1, [r0, #0x30]

  133.     ldr    r1, =DMC1_TIMING_ROW        /* timingRow */
  134.     str    r1, [r0, #0x34]

  135.     ldr    r1, =DMC1_TIMING_DATA        /* timing data CL=3 */
  136.     str    r1, [r0, #0x38]

  137.     ldr    r1, =DMC1_TIMING_PWR        /* timing power */
  138.     str    r1, [r0, #0x3c]

  139.     ldr    r1, =0x07000000                /* chip0 deselect */
  140.     str    r1, [r0, #0x10]

  141.     ldr    r1, =0x01000000                /* chip0 pall */
  142.     str    r1, [r0, #0x10]

  143.     ldr    r1, =0x00020000                /* chip0 emrs2 */
  144.     str    r1, [r0, #0x10]

  145.     ldr    r1, =0x00030000                /* chip0 emrs3 */
  146.     str    r1, [r0, #0x10]

  147.     ldr    r1, =0x00010400                /* chip0 emrs1 (mem dll on, dqs disable) */
  148.     str    r1, [r0, #0x10]

  149.     ldr    r1, =0x00000542                /* chip0 mrs (mem dll reset) cl=4, bl=4 */
  150.     str    r1, [r0, #0x10]

  151.     ldr    r1, =0x01000000                /* chip0 pall */
  152.     str    r1, [r0, #0x10]

  153.     ldr    r1, =0x05000000                /* chip0 refa */
  154.     str    r1, [r0, #0x10]

  155.     ldr    r1, =0x05000000                /* chip0 refa */
  156.     str    r1, [r0, #0x10]

  157.     ldr    r1, =0x00000442                /* chip0 mrs (mem dll unreset) */
  158.     str    r1, [r0, #0x10]

  159.     ldr    r1, =0x00010780                /* chip0 emrs1 (ocd default) */
  160.     str    r1, [r0, #0x10]

  161.     ldr    r1, =0x00010400                /* chip0 emrs1 (ocd exit) */
  162.     str    r1, [r0, #0x10]

  163.     ldr    r1, =0x07100000                /* chip1 deselect */
  164.     str    r1, [r0, #0x10]

  165.     ldr    r1, =0x01100000                /* chip1 pall */
  166.     str    r1, [r0, #0x10]

  167.     ldr    r1, =0x00120000                /* chip1 emrs2 */
  168.     str    r1, [r0, #0x10]

  169.     ldr    r1, =0x00130000                /* chip1 emrs3 */
  170.     str    r1, [r0, #0x10]

  171.     ldr    r1, =0x00110400                /* chip1 emrs1 (mem dll on, dqs disable) */
  172.     str    r1, [r0, #0x10]

  173.     ldr    r1, =0x00100542                /* chip1 mrs (mem dll reset) cl=4, bl=4 */
  174.     str    r1, [r0, #0x10]

  175.     ldr    r1, =0x01100000                /* chip1 pall */
  176.     str    r1, [r0, #0x10]

  177.     ldr    r1, =0x05100000                /* chip1 refa */
  178.     str    r1, [r0, #0x10]

  179.     ldr    r1, =0x05100000                /* chip1 refa */
  180.     str    r1, [r0, #0x10]

  181.     ldr    r1, =0x00100442                /* chip1 mrs (mem dll unreset) */
  182.     str    r1, [r0, #0x10]

  183.     ldr    r1, =0x00110780                /* chip1 emrs1 (ocd default) */
  184.     str    r1, [r0, #0x10]

  185.     ldr    r1, =0x00110400                /* chip1 emrs1 (ocd exit) */
  186.     str    r1, [r0, #0x10]

  187.     ldr    r1, =0x0FF02030                /* concontrol auto refresh on */
  188.     str    r1, [r0, #0x00]

  189.     ldr    r1, =0xFFFF00FF                /* pwrdn config */
  190.     str    r1, [r0, #0x28]

  191.     ldr    r1, =0x00202400                /* memcontrol bl=4, 1 chip, ddr2 type, dynamic self refresh, force precharge, dynamic power down off */
  192.     str    r1, [r0, #0x04]                /* 芯片数量改为1 chip了*/
  193.     mov    pc, lr


  194. .if (CLK_400_200_166_133 == 1) || (CLK_800_200_166_133 == 1) || (CLK_1000_200_166_133 == 1)
  195.     .equ DMC0_MEMCONFIG_0,        0x30F01313            //配置DMC0上的第1个DDR芯片,当地址高位为0x3x时,打开片选Xm0cs0,
  196.                                                     //1313表示linterleaved,[11:8]=3表示行地址10bit,[7:4]=1列地址13bit,最后的3表示8bank,那么Xm0CS1被设置为BA3,
  197.                                                     //不再作为片选功能
  198.                                                     //memconfig0 256MB config, 8 banks, mapping method[12:15] 0:linear, 1:linterleaved, 2:mixed */
  199.                                                     //
  200.                                                     
  201.     .equ DMC0_MEMCONFIG_1,        0x40F01323            //配置DMC0上的第2个DDR芯片,当地址高位为0x4x时,打开片选Xm0cs1,实际上不可用,后面会关闭掉这个chip
  202.                                                     //1323表示linterleaved,行地址10bit 列地址14bit 8bank,实际上后面会关闭掉这个chip,这句代码无效
  203.     .equ DMC0_TIMINGA_REF,        0x00000618
  204.     .equ DMC0_TIMING_ROW,        0x28233287
  205.     .equ DMC0_TIMING_DATA,        0x23240304
  206.     .equ DMC0_TIMING_PWR,        0x09C80232

  207.     .equ DMC1_MEMCONFIG_0,        0x40F01313            //配置DMC1上的第1个DDR芯片,当地址高位为0x3x时,打开片选Xm1cs0
  208.     .equ DMC1_MEMCONFIG_1,        0x00E01323            //配置DMC1上的第2个DDR芯片,当地址高位为0x4x时,打开片选Xm1cs1,实际上后面会关闭掉这个chip,这句代码无效
  209.     .equ DMC1_TIMINGA_REF,        0x00000618
  210.     .equ DMC1_TIMING_ROW,        0x28233289
  211.     .equ DMC1_TIMING_DATA,        0x23240304
  212.     .equ DMC1_TIMING_PWR,        0x08280232

  213. .endif

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