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

📄 rpxlite.c

📁 linux下的MTD设备驱动源代码,配合jffs2 yaffss2文件系统.
💻 C
字号:
/* * $Id: rpxlite.c,v 1.19 2003/05/21 12:45:19 dwmw2 Exp $ * * Handle mapping of the flash on the RPX Lite and CLLF boards */#include <linux/module.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/init.h>#include <asm/io.h>#include <linux/mtd/partitions.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#define WINDOW_ADDR 0xfe000000#define WINDOW_SIZE 0x800000static struct mtd_info *mymtd;static struct map_info rpxlite_map = {#ifndef CONFIG_RMU	.name = "RPX",#else	/* CONFIG_RMU */	.name =	"RMU",#endif /* CONFIG_RMU */	.size = WINDOW_SIZE,	.buswidth = 4,	.phys = WINDOW_ADDR,};#ifdef	CONFIG_RMU/* * The RMU seem to be working OK with a High BootLoader. Using this configuration * The 8MB Flash is used in the following way: *		0xFF800000-0xFFEFFFFF,	7MB:	Free *		0xFFF00000-0xFFF3FFFF, 256K:	BootLoader *		0xFFF40000-0xFFF7FFFF, 256K:	Environment 1 *		0xFFF80000-0xFFFBFFFF, 256K:	Environment 2 *		0xFFFC0000-0xFFFFFFFF, 256K:	Free * * In the configuration with 8 MB of flash memory, the RMU uses the * following partition map (relative to flash start at 0xFF800000): * *		4MB:	Kernel Image *		3MB:	Flash Filesystem *		256KB:	Bootloader *		256KB:	Environment 1 *		256KB:	Environment 2 *		256KB:	Spare */static struct mtd_partition rpxlite_partitions_8MB[] ={	{		name:		"Kernel Image",		size:		0x00400000,		offset:		0	},	{		name:		"Flash Filesystem",		size:		0x00300000,		offset:		MTDPART_OFS_APPEND	},	{		name:		"Bootloader",		size:		0x00040000,		offset:		MTDPART_OFS_APPEND	},	{		name:		"Environment 1",		size:		0x00040000,		offset:		MTDPART_OFS_APPEND	},	{		name:		"Environment 2",		size:		0x00040000,		offset:		MTDPART_OFS_APPEND	},	{		name:		"Spare",		size:		0x00040000,		offset:		MTDPART_OFS_APPEND	},};/* * In the configuration with 16 MB of flash memory, the RMU uses the * following partition map (relative to flash start at 0xFF000000): */static struct mtd_partition rpxlite_partitions_16MB[] ={	{		name:		"Kernel Image",		size:		0x00500000,		offset:		0	},	{		name:		"Flash Filesystem",		size:		0x00A00000,		offset:		MTDPART_OFS_APPEND	},	{		name:		"Bootloader",		size:		0x00040000,		offset:		MTDPART_OFS_APPEND	},	{		name:		"Environment 1",		size:		0x00040000,		offset:		MTDPART_OFS_APPEND	},	{		name:		"Environment 2",		size:		0x00040000,		offset:		MTDPART_OFS_APPEND	},	{		name:		"Spare",		size:		0x00040000,		offset:		MTDPART_OFS_APPEND	},};#define NB_OF(x)	(sizeof(x)/sizeof(x[0]))/* * Determines the size of the flash. */static unsigned long determine_flashSize (void){	volatile bd_t *bd = (bd_t *)__res;	return (bd->bi_flashsize);}#endif /* CONFIG_RMU */int __init init_rpxlite(void){#ifdef CONFIG_MTD_CMDLINE_PARTS	int n;	const char *part_probes[] = { "cmdlinepart", NULL };	struct mtd_partition * cmdline_parts;#endif#ifdef CONFIG_RMU	struct mtd_partition *parts;	int	nb_parts = 0;	switch (rpxlite_map.size = determine_flashSize ()) {	case 8 << 20:		/* 8 MB flash */		parts = rpxlite_partitions_8MB;		nb_parts = NB_OF (rpxlite_partitions_8MB);		rpxlite_map.size = (8 * 1024 * 1024);		break;	case 16 << 20:		/* 16 MB flash */		parts = rpxlite_partitions_16MB;		nb_parts = NB_OF (rpxlite_partitions_16MB);		rpxlite_map.size = (16 * 1024 * 1024);		break;	default:		printk (KERN_CRIT "RMU flash device with unexpected size: %ldMB\n",			rpxlite_map.size >> 20);		return -EIO;	}	rpxlite_map.phys = -rpxlite_map.size;	printk (KERN_NOTICE "RMU flash device: %ldMB at 0x%08lx\n",			rpxlite_map.size >> 20, rpxlite_map.phys);#else	/* CONFIG_RMU */	printk(KERN_NOTICE "RPX Lite or CLLF flash device: %lx at %lx\n", rpxlite_map.size, rpxlite_map.phys);#endif /* CONFIG_RMU */	rpxlite_map.virt = (unsigned long)ioremap(rpxlite_map.phys, rpxlite_map.size);	if (!rpxlite_map.virt) {		printk("Failed to ioremap\n");		return -EIO;	}	simple_map_init(&rpxlite_map);	mymtd = do_map_probe("cfi_probe", &rpxlite_map);	if (mymtd) {		mymtd->owner = THIS_MODULE;#ifdef CONFIG_MTD_CMDLINE_PARTS		n = parse_mtd_partitions(mymtd,		                         part_probes,		                         &cmdline_parts,		                         0);		if (n > 0) {			parts    = cmdline_parts;			nb_parts = n;		}#endif#ifdef CONFIG_RMU		return add_mtd_partitions (mymtd, parts, nb_parts);#else	/* CONFIG_RMU */		return 0;#endif /* CONFIG_RMU */	}	iounmap((void *)rpxlite_map.virt);	return -ENXIO;}static void __exit cleanup_rpxlite(void){	if (mymtd) {		del_mtd_device(mymtd);		map_destroy(mymtd);	}	if (rpxlite_map.virt) {		iounmap((void *)rpxlite_map.virt);		rpxlite_map.virt = 0;	}}module_init(init_rpxlite);module_exit(cleanup_rpxlite);MODULE_LICENSE("GPL");MODULE_AUTHOR("Arnold Christensen <AKC@pel.dk>");MODULE_DESCRIPTION("MTD map driver for RPX Lite and CLLF boards");

⌨️ 快捷键说明

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