⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sa1100-flash.c

📁 移植到2410开发板上的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifdef CONFIG_SA1100_JORNADA720#define JORNADA720_FLASH_SIZE		0x02000000static struct mtd_partition jornada720_partitions[] = {	{		name:		"JORNADA720 boot firmware",		size:		0x00040000,		offset:		0,		mask_flags:	MTD_WRITEABLE,  /* force read-only */	}, {		name:		"JORNADA720 kernel",		size:		0x000c0000,		offset:		0x00040000,	}, {		name:		"JORNADA720 params",		size:		0x00040000,		offset:		0x00100000,	}, {		name:		"JORNADA720 initrd",		size:		0x00100000,		offset:		0x00140000,	}, {		name:		"JORNADA720 root cramfs",		size:		0x00300000,		offset:		0x00240000,	}, {		name:		"JORNADA720 usr cramfs",		size:		0x00800000,		offset:		0x00540000,	}, {		name:		"JORNADA720 usr local",		size:		0  /* will expand to the end of the flash */		offset:		0x00d00000,	}};static void jornada720_set_vpp(int vpp){	if (vpp)		PPSR |= 0x80;	else		PPSR &= ~0x80;	PPDR |= 0x80;}#endif#ifdef CONFIG_SA1100_NANOENGINE/* nanoEngine has one 28F320B3B Flash part in bank 0: */#define NANOENGINE_FLASH_SIZE		0x00400000static struct mtd_partition nanoengine_partitions[] = {	{		name:		"nanoEngine boot firmware and parameter table",		size:		0x00010000,  /* 32K */		offset:		0x00000000,		mask_flags:	MTD_WRITEABLE,  /* force read-only */	},{		name:		"kernel/initrd reserved",		size:		0x002f0000,		offset:		0x00010000,	},{		name:		"experimental filesystem allocation",		size:		0x00100000,		offset:		0x00300000,	}};#endif#ifdef CONFIG_SA1100_PANGOLIN#define PANGOLIN_FLASH_SIZE		0x04000000static struct mtd_partition pangolin_partitions[] = {	{		name:		"boot firmware",		size:		0x00080000,		offset:		0x00000000,		mask_flags:	MTD_WRITEABLE,  /* force read-only */	}, {		name:		"kernel",		size:		0x00100000,		offset:		0x00080000,	}, {		name:		"initrd",		size:		0x00280000,		offset:		0x00180000,	}, {		name:		"initrd-test",		size:		0x03C00000,		offset:		0x00400000,	}};#endif#ifdef CONFIG_SA1100_PT_SYSTEM3/* erase size is 0x40000 == 256k partitions have to have this boundary */#define SYSTEM3_FLASH_SIZE		0x01000000static struct mtd_partition system3_partitions[] = {	{		name:		"BLOB",		size:		0x00040000,		offset:		0x00000000,		mask_flags:	MTD_WRITEABLE,  /* force read-only */	}, {		name:		"config",		size:		0x00040000,		offset:		MTDPART_OFS_APPEND,	}, {		name:		"kernel",		size:		0x00100000,		offset:		MTDPART_OFS_APPEND,	}, {		name:		"root",		size:		MTDPART_SIZ_FULL,		offset:		MTDPART_OFS_APPEND,	}};#endif#ifdef CONFIG_SA1100_SHANNON#define SHANNON_FLASH_SIZE		0x00400000static struct mtd_partition shannon_partitions[] = {	{		name: "BLOB boot loader",		offset: 0,		size: 0x20000	},	{		name: "kernel",		offset: MTDPART_OFS_APPEND,		size: 0xe0000	},	{ 		name: "initrd",		offset: MTDPART_OFS_APPEND,			size: MTDPART_SIZ_FULL	}};#endif#ifdef CONFIG_SA1100_SHERMAN#define SHERMAN_FLASH_SIZE		0x02000000static struct mtd_partition sherman_partitions[] = {	{		size:		0x50000,		offset:		0,	}, {		size:		0x70000,		offset:		MTDPART_OFS_APPEND,	}, {		size:		0x600000,		offset:		MTDPART_OFS_APPEND,	}, {		size:		0xA0000,		offset:		MTDPART_OFS_APPEND,	}};#endif#ifdef CONFIG_SA1100_SIMPAD#define SIMPAD_FLASH_SIZE		0x02000000static struct mtd_partition simpad_partitions[] = {	{		name:		"SIMpad boot firmware",		size:		0x00080000,		offset:		0,		mask_flags:	MTD_WRITEABLE,  /* force read-only */	}, {		name:		"SIMpad kernel",		size:		0x00100000,		offset:		0x00080000,	}, {#ifdef CONFIG_JFFS2_FS		name:		"SIMpad root jffs2",		size:		MTDPART_SIZ_FULL,		offset:		0x00180000,#else		name:		"SIMpad initrd",		size:		0x00300000,		offset:		0x00180000,	}, {		name:		"SIMpad root cramfs",		size:		0x00300000,		offset:		0x00480000,	}, {		name:		"SIMpad usr cramfs",		size:		0x005c0000,		offset:		0x00780000,	}, {		name:		"SIMpad usr local",		size:		MTDPART_SIZ_FULL,		offset:		0x00d40000,#endif	}};#endif /* CONFIG_SA1100_SIMPAD */#ifdef CONFIG_SA1100_STORK#define STORK_FLASH_SIZE		0x02000000static struct mtd_partition stork_partitions[] = {	{		name:		"STORK boot firmware",		size:		0x00040000,		offset:		0,		mask_flags:	MTD_WRITEABLE,  /* force read-only */	}, {		name:		"STORK params",		size:		0x00040000,		offset:		0x00040000,	}, {		name:		"STORK kernel",		size:		0x00100000,		offset:		0x00080000,	}, {#ifdef CONFIG_JFFS2_FS		name:		"STORK root jffs2",		offset:		0x00180000,		size:		MTDPART_SIZ_FULL,#else		name:		"STORK initrd",		size:		0x00100000,		offset:		0x00180000,	}, {		name:		"STORK root cramfs",		size:		0x00300000,		offset:		0x00280000,	}, {		name:		"STORK usr cramfs",		size:		0x00800000,		offset:		0x00580000,	}, {		name:		"STORK usr local",		offset:		0x00d80000,		size:		MTDPART_SIZ_FULL,#endif	}};#endif#ifdef CONFIG_SA1100_YOPY#define YOPY_FLASH_SIZE			0x08000000static struct mtd_partition yopy_partitions[] = {	{		name:		"boot firmware",		size:		0x00040000,		offset:		0x00000000,		mask_flags:	MTD_WRITEABLE,  /* force read-only */	}, {		name:		"kernel",		size:		0x00080000,		offset:		0x00080000,	}, {		name:		"initrd",		size:		0x00300000,		offset:		0x00100000,	}, {		name:		"root",		size:		0x01000000,		offset:		0x00400000,	}};#endifextern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts);extern int parse_bootldr_partitions(struct mtd_info *master, struct mtd_partition **pparts);static struct mtd_partition *parsed_parts;static struct mtd_info *mymtd;int __init sa1100_mtd_init(void){	struct mtd_partition *parts;	int nb_parts = 0, ret;	int parsed_nr_parts = 0;	const char *part_type;	unsigned long base = -1UL;	/* Default flash buswidth */	sa1100_map.buswidth = (MSC0 & MSC_RBW) ? 2 : 4;	/*	 * Static partition definition selection	 */	part_type = "static";#ifdef CONFIG_SA1100_ADSBITSY	if (machine_is_adsbitsy()) {		parts = adsbitsy_partitions;		nb_parts = ARRAY_SIZE(adsbitsy_partitions);		sa1100_map.size = ADSBITSY_FLASH_SIZE;		sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2 : 4;	}#endif#ifdef CONFIG_SA1100_ASSABET	if (machine_is_assabet()) {		parts = assabet_partitions;		nb_parts = ARRAY_SIZE(assabet_partitions);		sa1100_map.size = ASSABET_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_BADGE4	if (machine_is_badge4()) {		parts = badge4_partitions;		nb_parts = ARRAY_SIZE(badge4_partitions);		sa1100_map.size = BADGE4_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_CERF	if (machine_is_cerf()) {		parts = cerf_partitions;		nb_parts = ARRAY_SIZE(cerf_partitions);		sa1100_map.size = CERF_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_CONSUS	if (machine_is_consus()) {		parts = consus_partitions;		nb_parts = ARRAY_SIZE(consus_partitions);		sa1100_map.size = CONSUS_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_FLEXANET	if (machine_is_flexanet()) {		parts = flexanet_partitions;		nb_parts = ARRAY_SIZE(flexanet_partitions);		sa1100_map.size = FLEXANET_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_FREEBIRD	if (machine_is_freebird()) {		parts = freebird_partitions;		nb_parts = ARRAY_SIZE(freebird_partitions);		sa1100_map.size = FREEBIRD_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_FRODO	if (machine_is_frodo()) {		parts = frodo_partitions;		nb_parts = ARRAY_SIZE(frodo_partitions);		sa1100_map.size = FRODO_FLASH_SIZE;		base = 0x00000000;	}#endif#ifdef CONFIG_SA1100_GRAPHICSCLIENT	if (machine_is_graphicsclient()) {		parts = graphicsclient_partitions;		nb_parts = ARRAY_SIZE(graphicsclient_partitions);		sa1100_map.size = GRAPHICSCLIENT_FLASH_SIZE;		sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2:4;	}#endif#ifdef CONFIG_SA1100_GRAPHICSMASTER	if (machine_is_graphicsmaster()) {		parts = graphicsmaster_partitions;		nb_parts = ARRAY_SIZE(graphicsmaster_partitions);		sa1100_map.size = GRAPHICSMASTER_FLASH_SIZE;		sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2:4;	}#endif#ifdef CONFIG_SA1100_H3600	if (machine_is_h3600()) {		parts = h3600_partitions;		nb_parts = ARRAY_SIZE(h3600_partitions);		sa1100_map.size = H3600_FLASH_SIZE;		sa1100_map.set_vpp = h3600_set_vpp;	}#endif#ifdef CONFIG_SA1100_HUW_WEBPANEL	if (machine_is_huw_webpanel()) {		parts = huw_webpanel_partitions;		nb_parts = ARRAY_SIZE(huw_webpanel_partitions);		sa1100_map.size = HUW_WEBPANEL_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_JORNADA720	if (machine_is_jornada720()) {		parts = jornada720_partitions;		nb_parts = ARRAY_SIZE(jornada720_partitions);		sa1100_map.size = JORNADA720_FLASH_SIZE;		sa1100_map.set_vpp = jornada720_set_vpp;	}#endif#ifdef CONFIG_SA1100_NANOENGINE	if (machine_is_nanoengine()) {		parts = nanoengine_partitions;		nb_parts = ARRAY_SIZE(nanoengine_partitions);		sa1100_map.size = NANOENGINE_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_PANGOLIN	if (machine_is_pangolin()) {		parts = pangolin_partitions;		nb_parts = ARRAY_SIZE(pangolin_partitions);		sa1100_map.size = PANGOLIN_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_PT_SYSTEM3	if (machine_is_pt_system3()) {		parts = system3_partitions;		nb_parts = ARRAY_SIZE(system3_partitions);		sa1100_map.size = SYSTEM3_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_SHANNON	if (machine_is_shannon()) {		parts = shannon_partitions;		nb_parts = ARRAY_SIZE(shannon_partitions);		sa1100_map.size = SHANNON_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_SHERMAN	if (machine_is_sherman()) {		parts = sherman_partitions;		nb_parts = ARRAY_SIZE(sherman_partitions);		sa1100_map.size = SHERMAN_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_SIMPAD	if (machine_is_simpad()) {		parts = simpad_partitions;		nb_parts = ARRAY_SIZE(simpad_partitions);		sa1100_map.size = SIMPAD_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_STORK	if (machine_is_stork()) {		parts = stork_partitions;		nb_parts = ARRAY_SIZE(stork_partitions);		sa1100_map.size = STORK_FLASH_SIZE;	}#endif#ifdef CONFIG_SA1100_YOPY	if (machine_is_yopy()) {		parts = yopy_partitions;		nb_parts = ARRAY_SIZE(yopy_partitions);		sa1100_map.size = YOPY_FLASH_SIZE;	}#endif	/*	 * For simple flash devices, use ioremap to map the flash.	 */	if (base != (unsigned long)-1) {		if (!request_mem_region(base, sa1100_map.size, "flash"))			return -EBUSY;		sa1100_map.map_priv_2 = base;		sa1100_map.map_priv_1 = (unsigned long)				ioremap(base, sa1100_map.size);		ret = -ENOMEM;		if (!sa1100_map.map_priv_1)			goto out_err;	}	/*	 * Now let's probe for the actual flash.  Do it here since	 * specific machine settings might have been set above.	 */	printk(KERN_NOTICE "SA1100 flash: probing %d-bit flash bus\n", sa1100_map.buswidth*8);	mymtd = do_map_probe("jedec_probe", &sa1100_map);	if (!mymtd)		mymtd = do_map_probe("cfi_probe", &sa1100_map);	ret = -ENXIO;	if (!mymtd)		goto out_err;	mymtd->module = THIS_MODULE;	/*	 * Dynamic partition selection stuff (might override the static ones)	 */#ifdef CONFIG_MTD_REDBOOT_PARTS	if (parsed_nr_parts == 0) {		int ret = parse_redboot_partitions(mymtd, &parsed_parts);		if (ret > 0) {			part_type = "RedBoot";			parsed_nr_parts = ret;		}	}#endif#ifdef CONFIG_MTD_CMDLINE_PARTS	if (parsed_nr_parts == 0) {		int ret = parse_cmdline_partitions(mymtd, &parsed_parts, "sa1100");		if (ret > 0) {			part_type = "Command Line";			parsed_nr_parts = ret;		}	}#endif	if (parsed_nr_parts > 0) {		parts = parsed_parts;		nb_parts = parsed_nr_parts;	}	if (nb_parts == 0) {		printk(KERN_NOTICE "SA1100 flash: no partition info available, registering whole flash at once\n");		add_mtd_device(mymtd);	} else {		printk(KERN_NOTICE "Using %s partition definition\n", part_type);		add_mtd_partitions(mymtd, parts, nb_parts);	}	return 0; out_err:	if (sa1100_map.map_priv_2 != -1) {		iounmap((void *)sa1100_map.map_priv_1);		release_mem_region(sa1100_map.map_priv_2, sa1100_map.size);	}	return ret;}static void __exit sa1100_mtd_cleanup(void){	if (mymtd) {		del_mtd_partitions(mymtd);		map_destroy(mymtd);		if (parsed_parts)			kfree(parsed_parts);	}	if (sa1100_map.map_priv_2 != -1) {		iounmap((void *)sa1100_map.map_priv_1);		release_mem_region(sa1100_map.map_priv_2, sa1100_map.size);	}}module_init(sa1100_mtd_init);module_exit(sa1100_mtd_cleanup);MODULE_AUTHOR("Nicolas Pitre");MODULE_DESCRIPTION("SA1100 CFI map driver");MODULE_LICENSE("GPL");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -