一. 配置内核
<*> MemoryTechnology Device (MTD) support --->
<*> MTD concatenating support
-*- MTD partitioning support
<*> Direct char device access to MTD devices
-*- Common interface to block layer for MTD'translation layers'
<*> Caching block device access to MTD devices
<*> NAND Device Support --->
<M> Support for generic platform NAND driver
二.资源配置
static struct resource hepxa270_nand_flash_resource = {
.start = 0x02000000,
.end = 0x02000000 + (1 << MAX(HEPXA270_NAND_CLE, HEPXA270_NAND_ALE)),
.flags = IORESOURCE_MEM,
};
//nandflash只作数据存储,所以只分了一个区
static struct mtd_partition hepxa270_nand_flash_partitions[] = {
{
.name = "Application Data",
.offset = 0,
.size = MTDPART_SIZ_FULL
}
};
static void hepxa270_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
{
struct nand_chip *this = mtd->priv;
if (cmd == NAND_CMD_NONE)
return;
if (ctrl & NAND_CLE)
writeb(cmd, this->IO_ADDR_W + (1 << HEPXA270_NAND_CLE));
else
writeb(cmd, this->IO_ADDR_W + (1 << HEPXA270_NAND_ALE));
}
static const char *hepxa270_nand_flash_part_probe_types[] = {"cmdlinepart", NULL};
static struct platform_nand_data hepxa270_nand_flash_platdata = {
.chip = {
.nr_chips = 1,
.chip_offset = 0,
.nr_partitions = ARRAY_SIZE(hepxa270_nand_flash_partitions),
.partitions = hepxa270_nand_flash_partitions,
.chip_delay = 25,
.part_probe_types = hepxa270_nand_flash_part_probe_types,
},
.ctrl = {
.cmd_ctrl = hepxa270_nand_flash_cmd_ctl,
}
};
static struct platform_device hepxa270_nand_flash_device = {
.name = "gen_nand",
.id = 0,
.num_resources = 1,
.resource = &hepxa270_nand_flash_resource,
.dev = {
.platform_data = &hepxa270_nand_flash_platdata,
},
};
三,添加平台设备
static struct platform_device *hepxa270_platform_devices[] __initdata = {
&hepxa270_nand_flash_device,
};