pxa270(Xscale核)的nandflash移植

一.    配置内核

<*> 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,
};



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值