int nand_curr_device = -1;
nand_info_t nand_info[CFG_MAX_NAND_DEVICE];
static struct nand_chip nand_chip[CFG_MAX_NAND_DEVICE];
static const char default_nand_name[] = "nand";
extern int board_nand_init(struct nand_chip *nand);
NAND FLASH(控制器)基地址
CFG_NAND_BASE_LIST和CFG_NAND_BASE:
#ifndef CFG_NAND_BASE_LIST
#define CFG_NAND_BASE_LIST { CFG_NAND_BASE }
#endif
static ulong base_address[CFG_MAX_NAND_DEVICE] =CFG_N AND_BASE_LIST;
通常只有一块NAND FLASH,因此只需定义CFG_NAND_BASE即可,一般在include/configs/开发板.h中配置,如:
#define CFG_NAND_BASE 0x05000000
board_nand_init函数
nand_init_chip函数调用了board_nand_init函数,board_nand_init函数在./board/开发板名称/nand.c中实现,如下是范例:
int board_nand_init(struct nand_chip *nand)
{
/* 下面这4行的初始化,并不是每个板子都需要的,有NAND FLASH控制器的一般都通过其他方法实现了 */
nand->IO_ADDR_R = (void __iomem *)(void *)K9F2G08_DATA;
nand->IO_ADDR_W = (void __iomem *)(void *)K9F2G08_DATA;
nand->IO_COMMAND = (void __iomem *)(void *)K9F2G08_CLE;
nand->IO_ADDRESS = (void __iomem *)(void *)K9F2G08_ALE;
nand->options = NAND_SAMSUNG_LP_OPTIONS|NAND_NO_AUTOINCR;
nand->eccmode = NAND_ECC_SOFT;
nand->hwcontrol = epcm_nand_hwcontrol; //MUST have
nand->chip_delay = 18;
return 0;
}