mtd/drivers/mtd/maps epxa10db-flash.c,1.3,1.4

cdavies at infradead.org cdavies at infradead.org
Thu Aug 22 06:46:22 EDT 2002


Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv15797

Modified Files:
	epxa10db-flash.c 
Log Message:
Made a couple of changes so that we can aupport AMD flash on epxa 
development boards



Index: epxa10db-flash.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/epxa10db-flash.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- epxa10db-flash.c	4 Jul 2002 10:40:35 -0000	1.3
+++ epxa10db-flash.c	22 Aug 2002 10:46:19 -0000	1.4
@@ -32,6 +32,11 @@
 #include <linux/mtd/partitions.h>
 
 #include <asm/hardware.h>
+#ifdef CONFIG_EPXA10DB
+#define BOARD_NAME "EPXA10DB"
+#else
+#define BOARD_NAME "EPXA1DB"
+#endif
 
 static int nr_parts = 0;
 static struct mtd_partition *parts;
@@ -39,91 +44,94 @@
 static struct mtd_info *mymtd;
 
 extern int parse_redboot_partitions(struct mtd_info *, struct mtd_partition **);
-static int epxa10db_default_partitions(struct mtd_info *master, struct mtd_partition **pparts);
+static int epxa_default_partitions(struct mtd_info *master, struct mtd_partition **pparts);
 
-static __u8 epxa10db_read8(struct map_info *map, unsigned long ofs)
+static __u8 epxa_read8(struct map_info *map, unsigned long ofs)
 {
 	return __raw_readb(map->map_priv_1 + ofs);
 }
 
-static __u16 epxa10db_read16(struct map_info *map, unsigned long ofs)
+static __u16 epxa_read16(struct map_info *map, unsigned long ofs)
 {
 	return __raw_readw(map->map_priv_1 + ofs);
 }
 
-static __u32 epxa10db_read32(struct map_info *map, unsigned long ofs)
+static __u32 epxa_read32(struct map_info *map, unsigned long ofs)
 {
 	return __raw_readl(map->map_priv_1 + ofs);
 }
 
-static void epxa10db_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
+static void epxa_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
 {
 	memcpy_fromio(to, (void *)(map->map_priv_1 + from), len);
 }
 
-static void epxa10db_write8(struct map_info *map, __u8 d, unsigned long adr)
+static void epxa_write8(struct map_info *map, __u8 d, unsigned long adr)
 {
 	__raw_writeb(d, map->map_priv_1 + adr);
 	mb();
 }
 
-static void epxa10db_write16(struct map_info *map, __u16 d, unsigned long adr)
+static void epxa_write16(struct map_info *map, __u16 d, unsigned long adr)
 {
 	__raw_writew(d, map->map_priv_1 + adr);
 	mb();
 }
 
-static void epxa10db_write32(struct map_info *map, __u32 d, unsigned long adr)
+static void epxa_write32(struct map_info *map, __u32 d, unsigned long adr)
 {
 	__raw_writel(d, map->map_priv_1 + adr);
 	mb();
 }
 
-static void epxa10db_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
+static void epxa_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
 {
 	memcpy_toio((void *)(map->map_priv_1 + to), from, len);
 }
 
 
 
-static struct map_info epxa10db_map = {
-	name:		"EPXA10DB flash",
+static struct map_info epxa_map = {
+	name:		"EPXA flash",
 	size:		FLASH_SIZE,
 	buswidth:	2,
-	read8:		epxa10db_read8,
-	read16:		epxa10db_read16,
-	read32:		epxa10db_read32,
-	copy_from:	epxa10db_copy_from,
-	write8:		epxa10db_write8,
-	write16:	epxa10db_write16,
-	write32:	epxa10db_write32,
-	copy_to:	epxa10db_copy_to
+	read8:		epxa_read8,
+	read16:		epxa_read16,
+	read32:		epxa_read32,
+	copy_from:	epxa_copy_from,
+	write8:		epxa_write8,
+	write16:	epxa_write16,
+	write32:	epxa_write32,
+	copy_to:	epxa_copy_to
 };
 
 
-static int __init epxa10db_mtd_init(void)
+static int __init epxa_mtd_init(void)
 {
 	int i;
-	printk(KERN_NOTICE "Epxa10db flash device: %x at %x\n", FLASH_SIZE, FLASH_START);
-	epxa10db_map.map_priv_1 = (unsigned long)ioremap(FLASH_START, FLASH_SIZE);
-	if (!epxa10db_map.map_priv_1) {
-		printk("Failed to ioremap Epxa10db flash\n");
+	
+	printk(KERN_NOTICE "%s flash device: %x at %x\n", BOARD_NAME, FLASH_SIZE, FLASH_START);
+	epxa_map.map_priv_1 = (unsigned long)ioremap(FLASH_START, FLASH_SIZE);
+	if (!epxa_map.map_priv_1) {
+		printk("Failed to ioremap %s flash\n",BOARD_NAME);
 		return -EIO;
 	}
 
-	mymtd = do_map_probe("cfi_probe", &epxa10db_map);
+	mymtd = do_map_probe("cfi_probe", &epxa_map);
 	if (!mymtd) {
-		iounmap((void *)epxa10db_map.map_priv_1);
+		iounmap((void *)epxa_map.map_priv_1);
 		return -ENXIO;
 	}
 
 	mymtd->module = THIS_MODULE;
 
 	/* Unlock the flash device. */
-	for (i=0; i<mymtd->numeraseregions;i++){
-		int j;
-		for(j=0;j<mymtd->eraseregions[i].numblocks;j++){
-			mymtd->unlock(mymtd,mymtd->eraseregions[i].offset + j * mymtd->eraseregions[i].erasesize,mymtd->eraseregions[i].erasesize);
+	if(mymtd->unlock){
+		for (i=0; i<mymtd->numeraseregions;i++){
+			int j;
+			for(j=0;j<mymtd->eraseregions[i].numblocks;j++){
+				mymtd->unlock(mymtd,mymtd->eraseregions[i].offset + j * mymtd->eraseregions[i].erasesize,mymtd->eraseregions[i].erasesize);
+			}
 		}
 	}
 
@@ -145,7 +153,7 @@
 #endif
 
 	/* No recognised partitioning schemes found - use defaults */
-	nr_parts = epxa10db_default_partitions(mymtd, &parts);
+	nr_parts = epxa_default_partitions(mymtd, &parts);
 	if (nr_parts > 0) {
 		add_mtd_partitions(mymtd, parts, nr_parts);
 		return 0;
@@ -156,7 +164,7 @@
 	return 0;
 }
 
-static void __exit epxa10db_mtd_cleanup(void)
+static void __exit epxa_mtd_cleanup(void)
 {
 	if (mymtd) {
 		if (nr_parts)
@@ -165,9 +173,9 @@
 			del_mtd_device(mymtd);
 		map_destroy(mymtd);
 	}
-	if (epxa10db_map.map_priv_1) {
-		iounmap((void *)epxa10db_map.map_priv_1);
-		epxa10db_map.map_priv_1 = 0;
+	if (epxa_map.map_priv_1) {
+		iounmap((void *)epxa_map.map_priv_1);
+		epxa_map.map_priv_1 = 0;
 	}
 }
 
@@ -181,7 +189,7 @@
  * 0x00400000 - 0x00FFFFFF - Flashdisk
  */
 
-static int __init epxa10db_default_partitions(struct mtd_info *master, struct mtd_partition **pparts)
+static int __init epxa_default_partitions(struct mtd_info *master, struct mtd_partition **pparts)
 {
 	struct mtd_partition *parts;
 	int ret, i;
@@ -189,9 +197,10 @@
 	char *names; 
 	const char *name = "jffs";
 
-	printk("Using default partitions for epxa10db\n");
+	printk("Using default partitions for %s\n",BOARD_NAME);
 	npartitions=1;
 	parts = kmalloc(npartitions*sizeof(*parts)+strlen(name), GFP_KERNEL);
+	memzero(parts,npartitions*sizeof(*parts)+strlen(name));
 	if (!parts) {
 		ret = -ENOMEM;
 		goto out;
@@ -202,19 +211,23 @@
 	names += strlen(name) + 1;
 	strcpy(parts[i].name, name);
 
+#ifdef CONFIG_EPXA10DB
 	parts[i].size = FLASH_SIZE-0x00400000;
 	parts[i].offset = 0x00400000;
-	parts[i].mask_flags = 0;
-	parts[i].mtdp = 0;
+#else
+	parts[i].size = FLASH_SIZE-0x00180000;
+	parts[i].offset = 0x00180000;
+#endif
 
  out:
 	*pparts = parts;
 	return npartitions;
 }
 
-module_init(epxa10db_mtd_init);
-module_exit(epxa10db_mtd_cleanup);
+
+module_init(epxa_mtd_init);
+module_exit(epxa_mtd_cleanup);
 
 MODULE_AUTHOR("Clive Davies");
-MODULE_DESCRIPTION("Altera epxa10db mtd flash map");
+MODULE_DESCRIPTION("Altera epxa mtd flash map");
 MODULE_LICENSE("GPL");





More information about the linux-mtd-cvs mailing list