自己仿照uboot的nand驱动,就是那个nand_cp.c里,写了个小的读nand程序,为什么总是读出来的是0x30303030,nandflash是三星K9F2G08U0A。求大侠指导!!!static int nandll_read_page (unsigned char *buf, U32 addr, int large_block)
{
int i;
int page_size = 512;
char stat;
if (large_block)
page_size = 2048;
NAND_ENABLE_CE();
NF_CLEAR_RB();
NFCMD_REG = NAND_CMD_READ0;
/* Write Address */
NFADDR_REG = 0;
if (large_block)
NFADDR_REG = 0;
NFADDR_REG = (addr) & 0xff;
NFADDR_REG = (addr >> 8) & 0xff;
NFADDR_REG = (addr >> 16) & 0xff;
if (large_block)
NFCMD_REG = NAND_CMD_READSTART;
NF_TRANSRnB();
printk("wait pass\n");
NFCMD_REG=NAND_CMD_STATUS;
do
{
NFCMD_REG=NAND_CMD_STATUS;
stat=NFDATA8_REG;
}while(!(stat&=(1<<6)));
//NF_DETECT_RB();
/* for compatibility(2460). u32 cannot be used. by scsuh */
for(i=0; i < page_size; i++) {
*buf++ = NFDATA8_REG;
}
NFCMD_REG=NAND_CMD_RESET;
NAND_DISABLE_CE();
return 0;
} |