ddd
全部博文(22)
分类: 嵌入式
2010-04-25 13:57:57
4.1 Nand Flash 驱动
(1)修改/drivers/mtd/nand/s3c2410_nand.c,原来的nand驱动在/cpu/arm920t/s3c24x0/nand.c中文件名和放置的位置都已经改变。
#define NF_BASE 0x4e000000
#if defined(CONFIG_S
#define NFCONF __REGi(NF_BASE + 0x0)
#define NFCMD __REGb(NF_BASE + 0x4)
#define NFADDR __REGb(NF_BASE + 0x8)
#define NFDATA __REGb(NF_BASE + 0xc)
#define NFSTAT __REGb(NF_BASE + 0x10)
#define NFECC0 __REGb(NF_BASE + 0x14)
#define NFECC1 __REGb(NF_BASE + 0x15)
#define NFECC2 __REGb(NF_BASE + 0x16)
#define S
#define S
#define S
#define S
#define S
#define S
#define S
#define S
#define S
#define S
#endif
#if defined(CONFIG_S
#define S
#define S
#define NFCONF __REGi(NF_BASE + 0x0)
#define NFCONT __REGb(NF_BASE + 0x4)
#define NFCMD __REGb(NF_BASE + 0x8)
#define NFADDR __REGb(NF_BASE + 0xc)
#define NFDATA __REGb(NF_BASE + 0x10)
#define NFMECCD0 __REGb(NF_BASE + 0x14)
#define NFMECCD1 __REGb(NF_BASE + 0x18)
#define NFSECCD __REGb(NF_BASE + 0x
#define NFSTAT __REGb(NF_BASE + 0x20)
#define NFESTAT0 __REGb(NF_BASE + 0x24)
#define NFESTAT1 __REGb(NF_BASE + 0x28)
#define NFMECC0 __REGb(NF_BASE + 0x
#define NFMECC1 __REGb(NF_BASE + 0x30)
#define NFSECC __REGb(NF_BASE + 0x34)
#define NFSBLK __REGb(NF_BASE + 0x38)
#define NFEBLK __REGb(NF_BASE + 0x
#define NFECC0 __REGb(NF_BASE + 0x
#define NFECC1 __REGb(NF_BASE + 0x2d)
#define NFECC2 __REGb(NF_BASE + 0x2e)
#define S
#define S
#define S
#define S
#define S
#define S
#define S
#endif
(2)u-boot.2009.08自带的S
ulong IO_ADDR_W = NF_BASE;
static void s
{
//struct nand_chip *chip = mtd->priv;
DEBUGN("hwcontrol(): 0x%02x 0x%02x\n", cmd, ctrl);
if (ctrl & NAND_CTRL_CHANGE) {
//ulong IO_ADDR_W = NF_BASE;
IO_ADDR_W = NF_BASE;
if (!(ctrl & NAND_CLE))
IO_ADDR_W |= S
if (!(ctrl & NAND_ALE))
IO_ADDR_W |= S
//chip->IO_ADDR_W = (void *)IO_ADDR_W;
#if defined(CONFIG_S
if (ctrl & NAND_NCE)
NFCONF &= ~S
else
NFCONF |= S
}
#endif
#if defined(CONFIG_S
if (ctrl & NAND_NCE)
NFCONT &= ~S
else
NFCONT |= S
}
#endif
if (cmd != NAND_CMD_NONE)
//writeb(cmd, chip->IO_ADDR_W);
writeb(cmd, (void *)IO_ADDR_W);
}
#ifdef CONFIG_S
void s
{
DEBUGN("s
#if defined(CONFIG_S
NFCONF |= S
#endif
#if defined(CONFIG_S
NFCONT |= S
#endif
}
(3)修改board_nand_init 函数如下
int board_nand_init(struct nand_chip *nand)
{
u_int32_t cfg;
u_int8_t tacls, twrph0, twrph1;
S
DEBUGN("board_nand_init()\n");
clk_power->CLKCON |= (1 << 4);
#if defined(CONFIG_S
/* initialize hardware */
twrph0 = 3; twrph1 = 0; tacls = 0;
cfg = S
cfg |= S
cfg |= S
cfg |= S
NFCONF = cfg;
/* initialize nand_chip data structure */
nand->IO_ADDR_R = nand->IO_ADDR_W = (void *)0x4e
#endif
#if defined(CONFIG_S
twrph0 = 4; twrph1 = 2; tacls = 0;
cfg = 0;
cfg |= S
cfg |= S
cfg |= S
NFCONF = cfg;
NFCONT= (0<<13)|(0<<12)|(0<<10)|(0<<9)|(0<<8)|(0<<6)|(0<<5)|(1<<4)|(0<<1)|(1<<0);
/* initialize nand_chip data structure */
nand->IO_ADDR_R = nand->IO_ADDR_W = (void *)0x4e000010;
#endif
/* read_buf and write_buf are default */
/* read_byte and write_byte are default */