109:#define B5_Tacp 0x0
110:#define B5_PMC 0x0
111:
112:#define B6_MT 0x3
113:#define B6_Trcd 0x1
114:#define B6_SCAN 0x1
115:
116:#define B7_MT 0x3
117:#define B7_Trcd 0x1
118:#define B7_SCAN 0x1
119:
120:
121:#define REFEN 0x1
122:#define TREFMD 0x0
123:#define Trp 0x1
124:#define Trc 0x1
125:#define Tchr 0x2
126:#define REFCNT 1268
4.修改NandFlash相关内容。
尽管本次移植没有涉及到NandFlash,但为了能够编译成功,必须修改下面有关NandFlash的内容。
进入u-boot-2011.06目录,执行下列命令:
cp drivers/mtd/nand/s3c2410_nand.c drivers/mtd/nand/s3c2440_nand.c
打开drivers/mtd/nand/s3c2440_nand.c文件,把该文件内的所有有关“2410”的地方一律改为“2440”。
再打开drivers/mtd/nand/Makefile文件
第48行“COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o”改为
48:COBJS-$(CONFIG_NAND_S3C2440) += s3c2440_nand.o
编译u-boot,把编译生成的新的u-boot.bin烧写到NorFlash中。开发板上电启动后,则在超级终端(或类似的软件)中显示的结果为:
U-Boot 2011.06 (Jul 30 2011 - 23:40:44)
DRAM: 64 MiB
Flash: 2 MiB
NAND: raise: Signal # 8 caught
raise: Signal # 8 caught
raise: Signal # 8 caught
raise: Signal # 8 caught
raise: Signal # 8 caught
raise: Signal # 8 caught
No NAND device found!!!
0 MiB
*** Warning - bad CRC, using defaultenvironment
In: serial
Out: serial
Err: serial
Net: CS8900-0
gq2440 #
从上述显示的内容可以看出本开发板的一些基本的信息,如DRAM为64M,NorFlash为2M,由于我没有设置NandFlash,因此系统没有检测到NandFlash,命令提示符也已经修改为“gq2440 # ”。
在提示符下输入flinfo,则会把NorFlash的更详细的信息显示出来:
Bank # 1: CFI conformant flash (16 x16) Size: 2 MB in 35 Sectors
AMDStandard command set, Manufacturer ID: 0x1C,Device ID: 0x2249
Erase timeout: 16384 ms, write timeout: 1 ms
Sector Start Addresses:
00000000 RO 00004000 RO 00006000 RO 00008000 RO 00010000 RO
00020000 RO 00030000 RO 00040000 RO 00050000 RO 00060000 RO
00070000 RO 00080000 00090000 000A0000 000B0000
000C0000 000D0000 000E0000 000F0000 00100000
00110000 00120000 00130000 00140000 00150000
00160000 00170000 00180000 00190000 001A0000
001B0000 001C0000 001D0000 001E0000 001F0000
3 支持NandFlash读写
我们把drivers/mtd/nand/s3c2410_nand.c文件复制为s3c2440_nand.c文件,并把该文件内的所有有关“2410”的地方一律改为“2440”。这么修改仅仅是能够让系统编译成功,并没有真正实现NandFlash的读写。在这里,我们就来介绍如何让u-boot支持NandFlash的读写。
由于s3c2410与s3c2440的NandFlash控制器不一样,因此s3c2440_nand.c文件并不能直接应用,需要进行适当的修改,而主要修改的内容就是s3c2440的相关寄存器。
首先重新定义要用到的寄存器,把原文中第27行至第37行之间的宏定义去掉,改为下面的形式:
#define S3C2440_NFCONT_SECCL (1<<6)
#define S3C2440_NFCONT_MECCL (1<<5)
#define S3C2440_NFCONT_INITECC (1<<4)
#define S3C2440_NFCONT_nCE (1<<1)
#define S3C2440_NFCONT_MODE (1<<0)
#define S3C2440_NFCONF_TACLS(x) ((x)<<12)
#define S3C2440_NFCONF_TWRPH0(x) ((x)<<8)
#define S3C2440_NFCONF_TWRPH1(x) ((x)<<4)
#define S3C2440_ADDR_NALE 0x08
#define S3C2440_ADDR_NCLE 0x0C
然后就是修改s3c2440_hwcontrol函数和board_nand_init函数,其他函数不变。
board_nand_init函数主要是用于对NandFlash的初始化,对它修改的内容是对寄存器NFCONF和寄存器NFCONT的修改,如下所示为修改后的board_nand_init函数,其中红色标注的地方为修改的地方:
int board_nand_init(struct nand_chip *nand)
{
u_int32_t cfg;
u_int8_t tacls, twrph0, twrph1;
struct s3c24x0_clock_power *clk_power = s3c24x0_get_base_clock_power();
struct s3c2440_nand *nand_reg = s3c2440_get_base_nand();
debugX(1,'board_nand_init()n');
writel(readl(&clk_power->clkcon) |(1 << 4), &clk_power->clkcon);
#ifdefined(CONFIG_S3C24XX_CUSTOM_NAND_TIMING)
tacls = CONFIG_S3C24XX_TACLS;
twrph0 = CONFIG_S3C24XX_TWRPH0;
twrph1 = CONFIG_S3C24XX_TWRPH1;
#else
tacls = 2;
twrph0 = 3;
twrph1 = 1;
#endif
cfg = S3C2440_NFCONF_TACLS(tacls - 1);
cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1);
cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1);
writel(cfg,&nand_reg->nfconf);
cfg = S3C2440_NFCONT_SECCL;
cfg |= S3C2440_NFCONT_MECCL;
cfg |= S3C2440_NFCONT_MODE;
writel(cfg,&nand_reg->nfcont);
nand->IO_ADDR_R = (void*)&nand_reg->nfdata;
nand->IO_ADDR_W = (void*)&nand_reg->nfdata;
nand->select_chip = NULL;
#ifdefCONFIG_NAND_SPL
nand->read_buf = nand_read_buf;
#endif
nand->cmd_ctrl = s3c2440_hwcontrol;
nand->dev_ready = s3c2440_dev_ready;
#ifdefCONFIG_S3C2440_NAND_HWECC
nand->ecc.hwctl = s3c2440_nand_enable_hwecc;
nand->ecc.calculate = s3c2440_nand_calculate_ecc;
nand->ecc.correct = s3c2440_nand_correct_data;
nand->ecc.mode = NAND_ECC_HW;
nand->ecc.size =CONFIG_SYS_NAND_ECCSIZE;
nand->ecc.bytes =CONFIG_SYS_NAND_ECCBYTES;
#else
nand->ecc.mode = NAND_ECC_SOFT;
#endif
#ifdef CONFIG_S3C2440_NAND_BBT
nand->options = NAND_USE_FLASH_BBT;
#else
nand->options = 0;
#endif
debugX(1, 'end ofnand_initn');
return 0;
}
最后修改s3c2440_hwcontrol函数,该函数是用于对NandFlash的写命令和写地址操作:
static void s3c2440_hwcontrol(structmtd_info *mtd, int cmd, unsigned int ctrl)
{
struct nand_chip *chip =mtd->priv;
struct s3c2440_nand *nand = s3c2440_get_base_nand();
debugX(1,'hwcontrol(): 0xx 0xxn', cmd, ctrl);
if (ctrl &NAND_CTRL_CHANGE) {
ulong IO_ADDR_W = (ulong)nand;
if (!(ctrl &NAND_CLE))
上一篇:ALSA声卡10_从零编写之数据传输_学习笔记
下一篇:摄像头驱动学习
推荐阅读最新更新时间:2024-11-13 16:50