一、CPU访问芯片的条件

  

  CPU通过访问存储控制器,来读取外部设备的数据。

  CPU想访问一个芯片,需要如下条件(配置信息):

    • 地址线
    • 数据线:8位/16位/32位数据宽度
    • 时钟/频率 
    • 其他芯片相关的特性:比如SDRAM,有行地址、列地址和bank

  SDRAM的访问和表格检索的原理一样,先指定一个行(Row),再指定一个列(Columu),就可以准确找到所需要的单元格。这个单元格称为存储单元,这个表格(存储阵列)就是逻辑Bank(Logical Bank,即L-Bank),SDRAM一般含有4个L-bank。  

  

  只有配置好了存储管理器,才知道如何去访问外部的设备。

二、存储控制器访问SDRAM

  2.1 原理图

  

  CPU侧:

      

  

  

  

  

  可以看看这些引脚的功能,查看SDRAM的芯片手册。

  LADDR:地址接口

  

  LnWBE[0:3]:bank的操作方式

  

  LDATA:数据接口

  

  LnWE

  

  更多的看数据手册。

三、存储管理器的配置  

  • 位宽
  • 行列地址
  • 刷新周期

  详细寄存器可以查看DATASHEET。

四、2440启动方式

4.1 NAND FALSH启动

  

4.2 NOR FLASH

  

五、代码

  内存控制器初始化代码:

  这里我们是从nor flash启动,因此CONFIG_SYS_TEXT_BASE定义的参数为0x0。

  lowlevel_init.S (board\samsung\jz2440)

  1 #define BWSCON    0x48000000

 /* BWSCON */
#define DW8 (0x0)
#define DW16 (0x1)
#define DW32 (0x2)
#define WAIT (0x1<<2)
#define UBLB (0x1<<3) #define B1_BWSCON (DW32)
#define B2_BWSCON (DW16)
#define B3_BWSCON (DW16 + WAIT + UBLB)
#define B4_BWSCON (DW16)
#define B5_BWSCON (DW16)
#define B6_BWSCON (DW32)
#define B7_BWSCON (DW32) /* BANK0CON */
#define B0_Tacs 0x0 /* 0clk */
#define B0_Tcos 0x0 /* 0clk */
#define B0_Tacc 0x7 /* 14clk */
#define B0_Tcoh 0x0 /* 0clk */
#define B0_Tah 0x0 /* 0clk */
#define B0_Tacp 0x0
#define B0_PMC 0x0 /* normal */ /* BANK1CON */
#define B1_Tacs 0x0 /* 0clk */
#define B1_Tcos 0x0 /* 0clk */
#define B1_Tacc 0x7 /* 14clk */
#define B1_Tcoh 0x0 /* 0clk */
#define B1_Tah 0x0 /* 0clk */
#define B1_Tacp 0x0
#define B1_PMC 0x0 #define B2_Tacs 0x0
#define B2_Tcos 0x0
#define B2_Tacc 0x7
#define B2_Tcoh 0x0
#define B2_Tah 0x0
#define B2_Tacp 0x0
#define B2_PMC 0x0 #define B3_Tacs 0x0 /* 0clk */
#define B3_Tcos 0x3 /* 4clk */
#define B3_Tacc 0x7 /* 14clk */
#define B3_Tcoh 0x1 /* 1clk */
#define B3_Tah 0x0 /* 0clk */
#define B3_Tacp 0x3 /* 6clk */
#define B3_PMC 0x0 /* normal */ #define B4_Tacs 0x0 /* 0clk */
#define B4_Tcos 0x0 /* 0clk */
#define B4_Tacc 0x7 /* 14clk */
#define B4_Tcoh 0x0 /* 0clk */
#define B4_Tah 0x0 /* 0clk */
#define B4_Tacp 0x0
#define B4_PMC 0x0 /* normal */ #define B5_Tacs 0x0 /* 0clk */
#define B5_Tcos 0x0 /* 0clk */
#define B5_Tacc 0x7 /* 14clk */
#define B5_Tcoh 0x0 /* 0clk */
#define B5_Tah 0x0 /* 0clk */
#define B5_Tacp 0x0
#define B5_PMC 0x0 /* normal */ #define B6_MT 0x3 /* SDRAM */
#define B6_Trcd 0x1
#define B6_SCAN 0x1 /* 9bit */ #define B7_MT 0x3 /* SDRAM */
#define B7_Trcd 0x1 /* 3clk */
#define B7_SCAN 0x1 /* 9bit */ /* REFRESH parameter */
#define REFEN 0x1 /* Refresh enable */
#define TREFMD 0x0 /* CBR(CAS before RAS)/Auto refresh */
#define Trp 0x0 /* 2clk */
#define Trc 0x3 /* 7clk */
#define Tchr 0x2 /* 3clk */
#define REFCNT 1113 /* period=15.6us, HCLK=60Mhz, (2048+1-15.6*60) */
/**************************************/ .globl lowlevel_init
lowlevel_init:
/* memory control configuration */
/* make r0 relative the current location so that it */
/* reads SMRDATA out of FLASH rather than memory ! */
/* 初始化内存 */
ldr r0, =SMRDATA /* 将SMRDATA的首地址(第一个.long)内存单元数据放置到r0寄存器中 r0=eac */
ldr r1, =CONFIG_SYS_TEXT_BASE /* CONFIG_SYS_TEXT_BASE=0x0(include/configs/jz2440中定义)
代码的基地址 */
sub r0, r0, r1 /* r0 = r0 -r1 */
ldr r1, =BWSCON /* Bus Width Status Controller,BWSCON=0x48000000,此文件中定义 */
add r2, r0, #* /* 将SMRDATA这一块地址赋值给r2中 */
:
ldr r3, [r0], # /* 将r0的值代表的内存单元放入r3中,之后r0的值偏移4位 */
str r3, [r1], # /* 将r3的值放入r1的值代表的地址中,r1的值代表的地址偏移4位 */
cmp r2, r0 /* 比较r2 和 r0 ,若不相等则执行下一句*/
bne 0b /* 向后跳转到标签0处*/ /* everything is fine now */
mov pc, lr /* 返回 */ .ltorg
/* the literal pools origin */ /*
* 初始化存储控制器,经过此初始化之后,内存才可以使用
*/
/* 地址为 0x00000eb0 */
SMRDATA:
.long 0x22011110 //BWSCON
.long 0x00000700 //BANKCON0
.long 0x00000700 //BANKCON1
.long 0x00000700 //BANKCON2
.long 0x00000700 //BANKCON3
.long 0x00000740 //BANKCON4
.long 0x00000700 //BANKCON5
.long 0x00018005 //BANKCON6
.long 0x00018005 //BANKCON7
.long 0x008C04F4 //REFRESH
.long 0x000000B1 //BANKSIZE
.long 0x00000030 //MRSRB6
.long 0x00000030 //MRSRB7

u-boot移植(七)---代码修改---存储控制器的更多相关文章

  1. u-boot移植(八)---代码修改---存储控制器--MMU

    一.MMU介绍 1.1 虚拟地址与物理地址 建立两个应用程序,hello1.c和hello2.c,然后运行: hello1.c hello2.c 运行结果如下: 可以看到两个结果打印的地址是一样的,都 ...

  2. -boot移植(十一)---代码修改---支持nandflash

    一.移植前的修改 1.1 include/configs/jz2440修改 原来的定义: 可以看出,要先定义CONFIG_CMD_NAND才能使能NANDFlash. 这个在我们文件中的82行有定义, ...

  3. u-boot移植(五)---代码修改---时钟修改、SDRAM

    最开始已经建立了新单板以及配置文件,现在就需要做的是代码的修改,配置成适合目标板使用的u-boot. 一.时钟修改 在代码流程分析中,我们知道,系统的启动是: 设置 CPU 为管理员模式 关闭看门狗 ...

  4. u-boot移植(十二)---代码修改---支持DM9000网卡

    一.准备工作 1.1 原理图 CONFIG_DM9000_BASE 片选信号是接在nGCS4引脚,若要确定网卡的基地址,则要根据片选信号的接口去确定. 在三星2440的DATASHEET中memory ...

  5. s3c2440存储控制器和地址以及启动的理解

    转自:http://blog.sina.com.cn/s/blog_5ddb672b0100fkcf.html 1.首先应该先了解Flash ROM的种类 NOR FLASH地址线和数据线分开,来了地 ...

  6. ok6410 u-boot-2012.04.01移植七完善u-boot移植(u-boot移植结束)

    继ok6410 u-boot-2012.04.01移植六后,开发板已支持MLC NAND.DM9000等.但还需要完善比如环境变量.mtdpart分区.裁剪.制作补丁等.下面的工作就是完善移植的u-b ...

  7. JZ2440 裸机驱动 第6章 存储控制器

    本章目标:     了解S3C2410/S3C2440地址空间的布局     掌握如何通过总线形式访问扩展的外设,比如内存.NOR Flash.网卡等 ························ ...

  8. Spring Boot (七): Mybatis极简配置

    Spring Boot (七): Mybatis极简配置 1. 前言 ORM 框架的目的是简化编程中的数据库操作,经过这么多年的发展,基本上活到现在的就剩下两家了,一个是宣称可以不用写 SQL 的 H ...

  9. spring boot / cloud (七) 使用@Retryable来进行重处理

    spring boot / cloud (七) 使用@Retryable来进行重处理 前言 什么时候需要重处理? 在实际工作中,重处理是一个非常常见的场景,比如:发送消息失败,调用远程服务失败,争抢锁 ...

随机推荐

  1. Personal Software Process (PSP)

    日期 分类 开始时间 结束时间 中断时间 净时间 活动 备注 C U 2016/03/15 随笔 9:30 10:40 0 70 博客更新 更新<软件项目管理(1)> Y Minute 随 ...

  2. poj 3352 Road Construction(边双连通分量+缩点)

    题目链接:http://poj.org/problem?id=3352 这题和poj 3177 一样,参考http://www.cnblogs.com/frog112111/p/3367039.htm ...

  3. flask+mako+peewee(下)(解决了Error 2006: MySQL server has gone away)

    这篇主要介绍在这次项目中使用的peewee 文档地址:http://peewee.readthedocs.org/en/latest/index.html 首先我们要初始化一个数据库连接对象.这里我使 ...

  4. delphi property read writer 如何使用

    type TMyClass = class(TObject) private FMyName: string; FMyAge: Integer; procedure SetAge(age: Integ ...

  5. target存放的是编译后的.class文件地方 默认情况下不会讲非class文件放入进入 如果要使用非.class文件 需要通过增加配置方式自动加入文件

    target存放的是编译后的.class文件地方 默认情况下不会讲非class文件放入进入 如果要使用非.class文件 需要通过增加配置方式自动加入文件

  6. hdu 1025

    Problem Description JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which ...

  7. day11 高阶函数 函数式编程

    高阶函数,满足 接收函数作为参数或者返回有函数 函数可以当做参数传递给另一个函数 def foo(n): print(n) def bar(name): print("my name is ...

  8. Linux Install geoip

    安装方法 http://php.net/manual/en/geoip.installation.phpgeoip中的PHP函数介绍:http://php.net/manual/en/book.geo ...

  9. 切割模型固定写死了切平面方程是y=0.1

    上一篇讲到3d模型切割我遇到的问题(切面的纹理会混乱),经过这段时间的琢磨,有了解决方案,当然我这里只给出我的解决思路,投入到实际项目中还需要做许多工作,比如我在上一篇中切割模型固定写死了切平面方程是 ...

  10. Leetcode 283.移动零 By Python

    思路 我们可以用python的list comprehension来取出所以非0的元素,而且这样取出来会保持原有的相对顺序,再统计先后变化的长度,补上相应的0即可 代码 class Solution( ...