public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* cfi_cmdset_0002.c (AMD interleaved chips) fix
@ 2004-04-14 10:09 dkey
  2004-04-14 10:25 ` David Vrabel
  2004-04-14 23:29 ` Thayne Harbaugh
  0 siblings, 2 replies; 4+ messages in thread
From: dkey @ 2004-04-14 10:09 UTC (permalink / raw)
  To: linux-mtd, David Vrabel

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

hi,

attached a cif_cmdset_0002.c diff against the current cvs tested on AMD 
interleaved chips and it works!
thx @ David Vrable who provided this patch!!

greets dkey

[-- Attachment #2: cfi_cmdset_0002.c.diff --]
[-- Type: text/x-diff, Size: 17678 bytes --]

Index: cfi_cmdset_0002.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0002.c,v
retrieving revision 1.97
diff -u -r1.97 cfi_cmdset_0002.c
--- cfi_cmdset_0002.c	24 Feb 2004 13:50:21 -0000	1.97
+++ cfi_cmdset_0002.c	14 Apr 2004 09:58:04 -0000
@@ -90,7 +90,7 @@
 	};
 
 	printk("  Silicon revision: %d\n", extp->SiliconRevision >> 1);
-	printk("  Address sensitive unlock: %s\n", 
+	printk("  Address sensitive unlock: %s\n",
 	       (extp->SiliconRevision & 1) ? "Not required" : "Required");
 
 	if (extp->EraseSuspend < ARRAY_SIZE(erase_suspend))
@@ -115,9 +115,9 @@
 	else
 		printk("  Page mode: %d word page\n", extp->PageMode << 2);
 
-	printk("  Vpp Supply Minimum Program/Erase Voltage: %d.%d V\n", 
+	printk("  Vpp Supply Minimum Program/Erase Voltage: %d.%d V\n",
 	       extp->VppMin >> 4, extp->VppMin & 0xf);
-	printk("  Vpp Supply Maximum Program/Erase Voltage: %d.%d V\n", 
+	printk("  Vpp Supply Maximum Program/Erase Voltage: %d.%d V\n",
 	       extp->VppMax >> 4, extp->VppMax & 0xf);
 
 	if (extp->TopBottom < ARRAY_SIZE(top_bottom))
@@ -167,7 +167,7 @@
 	int i;
 
 	if (cfi->cfi_mode==CFI_MODE_CFI){
-		/* 
+		/*
 		 * It's a real CFI chip, not one for which the probe
 		 * routine faked a CFI structure. So we read the feature
 		 * table from it.
@@ -180,14 +180,14 @@
 			return NULL;
 
 		/* Install our own private info structure */
-		cfi->cmdset_priv = extp;	
+		cfi->cmdset_priv = extp;
 
 		cfi_fixup(map, fixup_table);
 
 #ifdef DEBUG_CFI_FEATURES
 		/* Tell the user about it in lots of lovely detail */
 		cfi_tell_features(extp);
-#endif	
+#endif
 
 		bootloc = extp->TopBottom;
 		if ((bootloc != 2) && (bootloc != 3)) {
@@ -198,11 +198,11 @@
 
 		if (bootloc == 3 && cfi->cfiq->NumEraseRegions > 1) {
 			printk(KERN_WARNING "%s: Swapping erase regions for broken CFI table.\n", map->name);
-			
+
 			for (i=0; i<cfi->cfiq->NumEraseRegions / 2; i++) {
 				int j = (cfi->cfiq->NumEraseRegions-1)-i;
 				__u32 swap;
-				
+
 				swap = cfi->cfiq->EraseRegionInfo[i];
 				cfi->cfiq->EraseRegionInfo[i] = cfi->cfiq->EraseRegionInfo[j];
 				cfi->cfiq->EraseRegionInfo[j] = swap;
@@ -215,8 +215,8 @@
 		if ( ! (cfi->addr_unlock1 && cfi->addr_unlock2) ) {
 			switch (cfi->device_type) {
 			case CFI_DEVICETYPE_X8:
-				cfi->addr_unlock1 = 0x555; 
-				cfi->addr_unlock2 = 0x2aa; 
+				cfi->addr_unlock1 = 0x555;
+				cfi->addr_unlock2 = 0x2aa;
 				break;
 			case CFI_DEVICETYPE_X16:
 				cfi->addr_unlock1 = 0xaaa;
@@ -228,8 +228,8 @@
 				}
 				break;
 			case CFI_DEVICETYPE_X32:
-				cfi->addr_unlock1 = 0x1555; 
-				cfi->addr_unlock2 = 0xaaa; 
+				cfi->addr_unlock1 = 0x1555;
+				cfi->addr_unlock2 = 0xaaa;
 				break;
 			default:
 				printk(KERN_WARNING
@@ -245,8 +245,8 @@
 		cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp;
 		cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp;
 		cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp;
-	}		
-	
+	}
+
 	map->fldrv = &cfi_amdstd_chipdrv;
 
 	return cfi_amdstd_setup(map);
@@ -262,7 +262,7 @@
 	int i,j;
 
 	mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
-	printk(KERN_NOTICE "number of %s chips: %d\n", 
+	printk(KERN_NOTICE "number of %s chips: %d\n",
 	       (cfi->cfi_mode == CFI_MODE_CFI)?"CFI":"JEDEC",cfi->numchips);
 
 	if (!mtd) {
@@ -273,22 +273,22 @@
 	memset(mtd, 0, sizeof(*mtd));
 	mtd->priv = map;
 	mtd->type = MTD_NORFLASH;
-	/* Also select the correct geometry setup too */ 
+	/* Also select the correct geometry setup too */
 	mtd->size = devsize * cfi->numchips;
 
 	mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
 	mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
 				    * mtd->numeraseregions, GFP_KERNEL);
-	if (!mtd->eraseregions) { 
+	if (!mtd->eraseregions) {
 		printk(KERN_WARNING "Failed to allocate memory for MTD erase region info\n");
 		goto setup_err;
 	}
-			
+
 	for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
 		unsigned long ernum, ersize;
 		ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave;
 		ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1;
-			
+
 		if (mtd->erasesize < ersize) {
 			mtd->erasesize = ersize;
 		}
@@ -355,7 +355,7 @@
 
 	/* does this chip have a secsi area? */
 	if(cfi->mfr==1){
-		
+
 		switch(cfi->id){
 		case 0x50:
 		case 0x53:
@@ -366,12 +366,12 @@
 			/* Yes */
 			mtd->read_user_prot_reg = cfi_amdstd_secsi_read;
 			mtd->read_fact_prot_reg = cfi_amdstd_secsi_read;
-		default:		       
+		default:
 			;
 		}
 	}
-	
-		
+
+
 	mtd->sync = cfi_amdstd_sync;
 	mtd->suspend = cfi_amdstd_suspend;
 	mtd->resume = cfi_amdstd_resume;
@@ -429,7 +429,7 @@
 	do {
 		d = cfi_read(map, addr);
 		t = d ^ cfi_read(map, addr);
-	
+
 		if (t == 0)		       /* no toggles -- Read or Erase-Suspend-Read mode */
 			return CHIP_READY;
 		if (!(t & ~dq2) && (t & dq2)) { /* only DQ2 toggling -- this sector is erase suspended */
@@ -447,10 +447,20 @@
 		}
 		/* some other bits toggled -- probably a program/erase just finished */
 	} while(retry--);
-	
+
 	return CHIP_ERROR;
 }
 
+static int chip_ready(struct map_info *map, unsigned long addr)
+{
+    cfi_word d, t;
+
+    d = cfi_read(map, addr);
+    t = d ^ cfi_read(map, addr);
+
+    return t == 0;
+}
+
 static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode)
 {
 	DECLARE_WAITQUEUE(wait, current);
@@ -465,7 +475,7 @@
 
 	case FL_STATUS:
 		for (;;) {
-			if (chip_status(map, adr) == CHIP_READY)
+			if (chip_ready(map, adr))
 				break;
 
 			if (time_after(jiffies, timeo)) {
@@ -479,7 +489,7 @@
 			/* Someone else might have been playing with it. */
 			goto retry;
 		}
-				
+
 	case FL_READY:
 	case FL_CFI_QUERY:
 	case FL_JEDEC_QUERY:
@@ -506,7 +516,7 @@
 		chip->state = FL_ERASE_SUSPENDING;
 		chip->erase_suspended = 1;
 		for (;;) {
-			if (chip_status(map, adr) == CHIP_READY)
+			if (chip_ready(map, adr))
 				break;
 
 			if (time_after(jiffies, timeo)) {
@@ -521,7 +531,7 @@
 				printk(KERN_ERR "MTD %s(): chip not ready after erase suspend\n", __func__);
 				return -EIO;
 			}
-			
+
 			cfi_spin_unlock(chip->mutex);
 			cfi_udelay(1);
 			cfi_spin_lock(chip->mutex);
@@ -581,8 +591,8 @@
 
 	adr += chip->start;
 
-	/* Ensure cmd read/writes are aligned. */ 
-	cmd_addr = adr & ~(CFIDEV_BUSWIDTH-1); 
+	/* Ensure cmd read/writes are aligned. */
+	cmd_addr = adr & ~(CFIDEV_BUSWIDTH-1);
 
 	cfi_spin_lock(chip->mutex);
 	ret = get_chip(map, chip, cmd_addr, FL_READY);
@@ -662,7 +672,7 @@
 #endif
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		add_wait_queue(&chip->wq, &wait);
-		
+
 		cfi_spin_unlock(chip->mutex);
 
 		schedule();
@@ -674,7 +684,7 @@
 		timeo = jiffies + HZ;
 
 		goto retry;
-	}	
+	}
 
 	adr += chip->start;
 
@@ -684,7 +694,7 @@
 	cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0x88, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
-	
+
 	map_copy_from(map, buf, adr, len);
 
 	/* should these be CFI_DEVICETYPE_X8 instead of cfi->device_type? */
@@ -692,7 +702,7 @@
 	cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0x90, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
 	cfi_send_gen_cmd(0x00, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
-	
+
 	wake_up(&chip->wq);
 	cfi_spin_unlock(chip->mutex);
 
@@ -805,7 +815,7 @@
 	cfi_spin_lock(chip->mutex);
 
 	/* See comment above for timeout value. */
-	timeo = jiffies + uWriteTimeout; 
+	timeo = jiffies + uWriteTimeout;
 	for (;;) {
 		if (chip->state != FL_WRITING) {
 			/* Someone's suspended the write. Sleep */
@@ -821,8 +831,11 @@
 			continue;
 		}
 
-		if ((status = chip_status(map, adr)) != CHIP_BUSY)
-			break;
+		if (chip_ready(map, adr))
+                        goto op_done;
+
+                if (time_after(jiffies, timeo))
+                        break;
 
 		/* Latency issues. Drop the lock, wait a while and retry */
 		cfi_spin_unlock(chip->mutex);
@@ -833,15 +846,8 @@
 	if (status == CHIP_READY)
 		goto op_done;
 
-	if (status == CHIP_TIMEDOUT)
-		printk(KERN_WARNING "MTD %s(): flash internal timeout\n",
-		       __func__);
-	else if (ta)
-		printk(KERN_WARNING "MTD %s(): software timeout\n",
-		       __func__ );
-	else
-		printk(KERN_WARNING "MTD %s(): unexpected failure.  status = %d\n",
-			__func__, status);
+	printk(KERN_WARNING "MTD %s(): software timeout\n",
+               __func__ );
 
  op_failed:
 	/* reset on all failures. */
@@ -929,23 +935,23 @@
 			return -EINVAL;
 		}
 
-		ret = do_write_oneword(map, &cfi->chips[chipnum], 
+		ret = do_write_oneword(map, &cfi->chips[chipnum],
 				       bus_ofs, datum);
-		if (ret) 
+		if (ret)
 			return ret;
-		
+
 		ofs += n;
 		buf += n;
 		(*retlen) += n;
 
 		if (ofs >> cfi->chipshift) {
-			chipnum ++; 
+			chipnum ++;
 			ofs = 0;
 			if (chipnum == cfi->numchips)
 				return 0;
 		}
 	}
-	
+
 	/* We are now aligned, write as much as possible */
 	while(len >= CFIDEV_BUSWIDTH) {
 		cfi_word datum;
@@ -976,7 +982,7 @@
 		len -= CFIDEV_BUSWIDTH;
 
 		if (ofs >> cfi->chipshift) {
-			chipnum ++; 
+			chipnum ++;
 			ofs = 0;
 			if (chipnum == cfi->numchips)
 				return 0;
@@ -1032,11 +1038,11 @@
 			return -EINVAL;
 		}
 
-		ret = do_write_oneword(map, &cfi->chips[chipnum], 
+		ret = do_write_oneword(map, &cfi->chips[chipnum],
 				ofs, datum);
-		if (ret) 
+		if (ret)
 			return ret;
-		
+
 		(*retlen) += n;
 	}
 
@@ -1047,7 +1053,7 @@
 /*
  * FIXME: interleaved mode not tested, and probably not supported!
  */
-static inline int do_write_buffer(struct map_info *map, struct flchip *chip, 
+static inline int do_write_buffer(struct map_info *map, struct flchip *chip,
 				  unsigned long adr, const u_char *buf, int len)
 {
 	struct cfi_private *cfi = map->fldrv_priv;
@@ -1168,8 +1174,8 @@
 	cfi_udelay(chip->buffer_write_time);
 	cfi_spin_lock(chip->mutex);
 
-	timeo = jiffies + uWriteTimeout; 
-		
+	timeo = jiffies + uWriteTimeout;
+
 	for (;;) {
 		if (chip->state != FL_WRITING) {
 			/* Someone's suspended the write. Sleep */
@@ -1185,10 +1191,11 @@
 			continue;
 		}
 
-		if( (status = chip_status(map, adr)) != CHIP_BUSY
-		    || ( ta = time_after(jiffies, timeo)) ) {
+		if (chip_ready(map, adr))
+                        goto op_done;
+
+		if( time_after(jiffies, timeo))
 			break;
-		}
 
 		/* Latency issues. Drop the lock, wait a while and retry */
 		cfi_spin_unlock(chip->mutex);
@@ -1197,19 +1204,8 @@
 	}
 
 
-	if (status == CHIP_READY)
-		goto op_done;
-
-	if (status == CHIP_TIMEDOUT) {
-		printk(KERN_WARNING "MTD %s(): flash internal timeout\n",
-		       __func__);
-	}
-	else if (ta)
-		printk(KERN_WARNING "MTD %s(): software timeout\n",
-		       __func__ );
-	else
-		printk(KERN_WARNING "MTD %s(): unexpected failure.  status = %d\n",
-			__func__, status);
+	 printk(KERN_WARNING "MTD %s(): software timeout\n",
+               __func__ );
 
  op_failed:
 	/* reset on all failures. */
@@ -1271,7 +1267,7 @@
 
 		if (size > len)
 			size = len;
-		ret = do_write_buffer(map, &cfi->chips[chipnum], 
+		ret = do_write_buffer(map, &cfi->chips[chipnum],
 				      ofs, buf, size);
 		if (ret)
 			return ret;
@@ -1282,7 +1278,7 @@
 		len -= size;
 
 		if (ofs >> cfi->chipshift) {
-			chipnum ++; 
+			chipnum ++;
 			ofs = 0;
 			if (chipnum == cfi->numchips)
 				return 0;
@@ -1356,10 +1352,12 @@
 			chip->erase_suspended = 0;
 		}
 
-		if ((status = chip_status(map, adr)) != CHIP_BUSY
-		    || ( ta = time_after(jiffies, timeo)) )
+		if (chip_ready(map, adr))
+                        goto op_done;
+
+                if (time_after(jiffies, timeo))
 			break;
-		
+
 		/* Latency issues. Drop the lock, wait a while and retry */
 		cfi_spin_unlock(chip->mutex);
 		set_current_state(TASK_UNINTERRUPTIBLE);
@@ -1367,18 +1365,8 @@
 		cfi_spin_lock(chip->mutex);
 	}
 
-	if (status == CHIP_READY)
-		goto op_done;
-
-	if (status == CHIP_TIMEDOUT)
-		printk(KERN_WARNING "MTD %s(): flash internal timeout\n",
-		       __func__);
-	else if (ta)
-		printk(KERN_WARNING "MTD %s(): software timeout\n",
-		       __func__ );
-	else
-		printk(KERN_WARNING "MTD %s(): unexpected failure.  status = %d\n",
-		       __func__, status);
+	 printk(KERN_WARNING "MTD %s(): software timeout\n",
+               __func__ );
 
  op_failed:
 	/* reset on all failures. */
@@ -1421,17 +1409,17 @@
 
 	i = 0;
 
-	/* Skip all erase regions which are ended before the start of 
+	/* Skip all erase regions which are ended before the start of
 	   the requested erase. Actually, to save on the calculations,
 	   we skip to the first erase region which starts after the
 	   start of the requested erase, and then go back one.
 	*/
-	
+
 	while (i < mtd->numeraseregions && ofs >= regions[i].offset)
 	       i++;
 	i--;
 
-	/* OK, now i is pointing at the erase region in which this 
+	/* OK, now i is pointing at the erase region in which this
 	   erase request starts. Check the start of the requested
 	   erase range is aligned with the erase size which is in
 	   effect here.
@@ -1454,7 +1442,7 @@
 	   the address actually falls
 	*/
 	i--;
-	
+
 	if ((ofs + len) & (regions[i].erasesize-1))
 		return -EINVAL;
 
@@ -1465,7 +1453,7 @@
 
 	while (len) {
 		ret = (*frob)(map, &cfi->chips[chipnum], adr, thunk);
-		
+
 		if (ret)
 			return ret;
 
@@ -1478,7 +1466,7 @@
 		if (adr >> cfi->chipshift) {
 			adr = 0;
 			chipnum++;
-			
+
 			if (chipnum >= cfi->numchips)
 			break;
 		}
@@ -1520,7 +1508,7 @@
 	chip->state = FL_ERASING;
 	chip->erase_suspended = 0;
 	chip->in_progress_block_addr = adr;
-	
+
 	cfi_spin_unlock(chip->mutex);
 	set_current_state(TASK_UNINTERRUPTIBLE);
 	schedule_timeout((chip->erase_time*HZ)/(2*1000));
@@ -1546,10 +1534,12 @@
 			chip->erase_suspended = 0;
 		}
 
-		if ((status = chip_status(map, adr)) != CHIP_BUSY
-		    || ( ta = time_after(jiffies, timeo)) )
+		if (chip_ready(map, adr))
+                        goto op_done;
+
+                if (time_after(jiffies, timeo))
 			break;
-		
+
 		/* Latency issues. Drop the lock, wait a while and retry */
 		cfi_spin_unlock(chip->mutex);
 		set_current_state(TASK_UNINTERRUPTIBLE);
@@ -1557,18 +1547,8 @@
 		cfi_spin_lock(chip->mutex);
 	}
 
-	if (status == CHIP_READY)
-		goto op_done;
-
-	if (status == CHIP_TIMEDOUT)
-		printk(KERN_WARNING "MTD %s(): flash internal timeout\n",
-		       __func__);
-	else if (ta)
-		printk(KERN_WARNING "MTD %s(): software timeout\n",
-		       __func__ );
-	else
-		printk(KERN_WARNING "MTD %s(): unexpected failure.  status = %d\n",
-		       __func__, status);
+	printk(KERN_WARNING "MTD %s(): software timeout\n",
+               __func__ );
 
  op_failed:
 	/* reset on all failures. */
@@ -1599,7 +1579,7 @@
 	instr->state = MTD_ERASE_DONE;
 	if (instr->callback)
 		instr->callback(instr);
-	
+
 	return 0;
 }
 
@@ -1623,7 +1603,7 @@
 	instr->state = MTD_ERASE_DONE;
 	if (instr->callback)
 		instr->callback(instr);
-	
+
 	return 0;
 }
 
@@ -1650,7 +1630,7 @@
 		case FL_JEDEC_QUERY:
 			chip->oldstate = chip->state;
 			chip->state = FL_SYNCING;
-			/* No need to wake_up() on this state change - 
+			/* No need to wake_up() on this state change -
 			 * as the whole point is that nobody can do anything
 			 * with the chip now anyway.
 			 */
@@ -1661,13 +1641,13 @@
 		default:
 			/* Not an idle state */
 			add_wait_queue(&chip->wq, &wait);
-			
+
 			cfi_spin_unlock(chip->mutex);
 
 			schedule();
 
 			remove_wait_queue(&chip->wq, &wait);
-			
+
 			goto retry;
 		}
 	}
@@ -1678,7 +1658,7 @@
 		chip = &cfi->chips[i];
 
 		cfi_spin_lock(chip->mutex);
-		
+
 		if (chip->state == FL_SYNCING) {
 			chip->state = chip->oldstate;
 			wake_up(&chip->wq);
@@ -1708,7 +1688,7 @@
 		case FL_JEDEC_QUERY:
 			chip->oldstate = chip->state;
 			chip->state = FL_PM_SUSPENDED;
-			/* No need to wake_up() on this state change - 
+			/* No need to wake_up() on this state change -
 			 * as the whole point is that nobody can do anything
 			 * with the chip now anyway.
 			 */
@@ -1729,7 +1709,7 @@
 			chip = &cfi->chips[i];
 
 			cfi_spin_lock(chip->mutex);
-		
+
 			if (chip->state == FL_PM_SUSPENDED) {
 				chip->state = chip->oldstate;
 				wake_up(&chip->wq);
@@ -1737,7 +1717,7 @@
 			cfi_spin_unlock(chip->mutex);
 		}
 	}
-	
+
 	return ret;
 }
 
@@ -1750,11 +1730,11 @@
 	struct flchip *chip;
 
 	for (i=0; i<cfi->numchips; i++) {
-	
+
 		chip = &cfi->chips[i];
 
 		cfi_spin_lock(chip->mutex);
-		
+
 		if (chip->state == FL_PM_SUSPENDED) {
 			chip->state = FL_READY;
 			cfi_write(map, CMD(0xF0), chip->start);
@@ -1782,7 +1762,7 @@
 	printk(KERN_DEBUG "block status register for 0x%08lx is %x\n",
 	       adr, cfi_read_query(map, adr+(2*ofs_factor)));
 	cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL);
-	
+
 	return 0;
 }
 
@@ -1842,7 +1822,7 @@
 
 	chip->state = xxlt->state;
 	cfi_write(map, CMD(xxlt->val), adr);
-	
+
 	/* Done and happy. */
 	chip->state = FL_READY;
 	put_chip(map, chip, adr);
@@ -1864,7 +1844,7 @@
 
 	ret = cfi_amdstd_varsize_frob(mtd, do_xxlock_oneblock, ofs, len,
 				      (void *)&DO_XXLOCK_ONEBLOCK_LOCK);
-	
+
 	DEBUG(MTD_DEBUG_LEVEL3,
 	      "%s: lock status after, ret=%d\n",
 	      __func__, ret);
@@ -1888,12 +1868,12 @@
 
 	ret = cfi_amdstd_varsize_frob(mtd, do_xxlock_oneblock, ofs, len,
 				      (void *)&DO_XXLOCK_ONEBLOCK_UNLOCK);
-	
+
 	DEBUG(MTD_DEBUG_LEVEL3,
 	      "%s: lock status after, ret=%d\n",
 	      __func__, ret);
 	debug_dump_locks(mtd, do_printlockstatus_oneblock, ofs, len, 0);
-	
+
 	return ret;
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cfi_cmdset_0002.c (AMD interleaved chips) fix
  2004-04-14 10:09 cfi_cmdset_0002.c (AMD interleaved chips) fix dkey
@ 2004-04-14 10:25 ` David Vrabel
  2004-04-14 23:29 ` Thayne Harbaugh
  1 sibling, 0 replies; 4+ messages in thread
From: David Vrabel @ 2004-04-14 10:25 UTC (permalink / raw)
  To: linux-mtd

dkey wrote:
> 
> attached a cif_cmdset_0002.c diff against the current cvs tested on AMD 
> interleaved chips and it works!

Excellent! Thanks for taking the time to test it and posting the results.

I'll have to find time to test it here before checking the change into 
CVS though.

David Vrabel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: cfi_cmdset_0002.c (AMD interleaved chips) fix
  2004-04-14 10:09 cfi_cmdset_0002.c (AMD interleaved chips) fix dkey
  2004-04-14 10:25 ` David Vrabel
@ 2004-04-14 23:29 ` Thayne Harbaugh
  1 sibling, 0 replies; 4+ messages in thread
From: Thayne Harbaugh @ 2004-04-14 23:29 UTC (permalink / raw)
  To: dkey; +Cc: linux-mtd

On Wed, 2004-04-14 at 04:09, dkey wrote:
> hi,
> 
> attached a cif_cmdset_0002.c diff against the current cvs tested on AMD 
> interleaved chips and it works!
> thx @ David Vrable who provided this patch!!

Nice that it works.

FWIW, next time you diff, use "-b".  The patch was very difficult to
read because there were more lines with whitespace changes than lines
that had code changes.

Thanks.

-- 
Thayne Harbaugh
Linux Networx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* cfi_cmdset_0002.c (AMD interleaved chips) fix
@ 2004-04-20 21:15 Bob Coggeshall
  0 siblings, 0 replies; 4+ messages in thread
From: Bob Coggeshall @ 2004-04-20 21:15 UTC (permalink / raw)
  To: linux-mtd

	
I've been trying to get a pair of interleaved Am29LV640  parts on a
mpc852 (watered down '866) to work using this patch and it still does 
not work --

When I insmod the mapping module it *looks* like everything comes up OK, 
and reads appear to work also. One suspicious thing is while gen_probe() reports
2 AMD/Fuji x16 parts, cfi_amdstd_setup() is  reporting cfi->numchips set at 1.

My config and and boot messages follow...

my kernel config: 

    CONFIG_MTD_GEN_PROBE=m
    CONFIG_MTD_CFI_ADV_OPTIONS=y
    CONFIG_MTD_CFI_NOSWAP=y
    # CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
    # CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
    CONFIG_MTD_CFI_GEOMETRY=y
    # CONFIG_MTD_CFI_B1 is not set
    # CONFIG_MTD_CFI_B2 is not set
    CONFIG_MTD_CFI_B4=y
    # CONFIG_MTD_CFI_B8 is not set
    # CONFIG_MTD_CFI_I1 is not set
    CONFIG_MTD_CFI_I2=y
    # CONFIG_MTD_CFI_I4 is not set
    # CONFIG_MTD_CFI_I8 is not set
    # CONFIG_MTD_CFI_INTELEXT is not set
    CONFIG_MTD_CFI_AMDSTD=m
    # CONFIG_MTD_CFI_STAA is not set
    CONFIG_MTD_CFI_UTIL=m
    CONFIG_MTD_RAM=m
    CONFIG_MTD_ROM=m
    # CONFIG_MTD_ABSENT is not set
    # CONFIG_MTD_OBSOLETE_CHIPS is not set
    # CONFIG_MTD_AMDSTD is not set
    # CONFIG_MTD_SHARP is not set
    # CONFIG_MTD_JEDEC is not set
    # CONFIG_MTD_COMPLEX_MAPPINGS is not set
    CONFIG_MTD_PHYSMAP=y
    CONFIG_MTD_EP852=m
    # CONFIG_MTD_CFI_FLAGADM is not set
    # CONFIG_MTD_PCI is not set
    # CONFIG_MTD_PCMCIA is not set
    # Self-contained MTD device drivers
    # CONFIG_MTD_PMC551 is not set
    CONFIG_MTD_SLRAM=m
    CONFIG_MTD_MTDRAM=m
    CONFIG_MTDRAM_TOTAL_SIZE=0
    CONFIG_MTDRAM_ERASE_SIZE=128
    CONFIG_MTD_BLKMTD=m
    # CONFIG_MTD_DOC2000 is not set
    # CONFIG_MTD_DOC2001 is not set
    # CONFIG_MTD_DOC2001PLUS is not set
    # CONFIG_MTD_DOCPROBE is not set
    # CONFIG_MTD_NAND is not set
    #

Boot up

    Linux version 2.4.22-pre8 (coggs@fracadeux) (gcc version 2.95.4 20010319 (prerelease/franzo/20011204)) #22 Tue
    Apr 20 13:40:57 PDT 2004
    On node 0 totalpages: 16384
    zone(0): 16384 pages.
    zone(1): 0 pages.
    zone(2): 0 pages.
    Kernel command line: console=ttyS0,9600 console=tty0 root=/dev/ram0 init=/linuxrc rw
    Decrementer Frequency = 375000000/60
    Calibrating delay loop... 99.73 BogoMIPS
    Memory: 60984k available (1052k kernel code, 464k data, 56k init, 0k highmem)
    Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)
    Inode cache hash table entries: 4096 (order: 3, 32768 bytes)
    Mount cache hash table entries: 512 (order: 0, 4096 bytes)
    Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
    Page-cache hash table entries: 16384 (order: 4, 65536 bytes)
    POSIX conformance testing by UNIFIX
    Linux NET4.0 for Linux 2.4
    Based upon Swansea University Computer Society NET3.039
    Initializing RT netlink socket
    Starting kswapd
    devfs: v1.12c (20020818) Richard Gooch (rgooch@atnf.csiro.au)
    devfs: boot_options: 0x1
    CPM UART driver version 0.03
    ttyS0 at 0x0280 is on SMC1 using BRG3 - SMC1/SCC3/I2C/SPI Patch enabled
    ttyS1 at 0x0200 is on SCC3 using BRG3
    ttyS2 at 0x0300 is on SCC4 using BRG4
    pty: 256 Unix98 ptys configured
    Generic RTC Driver v1.07
    eth0: FEC ENET Version 0.3, FEC irq 3, addr 00:10:ec:80:4a:c4
    RAMDISK driver initialized: 8 RAM disks of 12288K size 1024 blocksize
    loop: loaded (max 8 devices)
    NET4: Linux TCP/IP 1.0 for NET4.0
    IP Protocols: ICMP, UDP, TCP, IGMP
    IP: routing cache hash table of 512 buckets, 4Kbytes
    TCP: Hash tables configured (established 4096 bind 4096)
    NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
    RAMDISK: Compressed image found at block 0
    Freeing initrd memory: 2190k freed
    VFS: Mounted root (ext2 filesystem).
    Mounted devfs on /dev
    Freeing unused kernel memory: 56k init
    init started:  BusyBox v1.00-pre8 (2004.04.01-23:23+0000) multi-cUsing /lib/modules/mtdcore.o
>   Using /lib/modules/mtdchar.o
>   Using /lib/modules/chipreg.o
>   Using /lib/modules/gen_probe.o
>   Using /lib/modules/cfi_probe.o
>   Using /lib/modules/cfi_util.o
>   Using /lib/modules/cfi_cmdset_0002.o
>   Using /lib/modules/mtdpart.o
>   Using /lib/modules/cmdlinepart.o


Insmoding the mapping module: 
    #
    # insmod ep852-mtd.o
    Using ep852-mtd.o
    EP852 partitioned flash device: 4000000 at ff000000
    RPX: Found 2 x16 devices at 0x0 in 32-bit mode
     Amd/Fujitsu Extended Query Table at 0x0040
      Silicon revision: 4
      Address sensitive unlock: Required
      Erase Suspend: Read/write
      Block protection: 1 sectors per group
      Temporary block unprotect: Supported
      Block protect/unprotect scheme: 4
      Number of simultaneous operations: 0
      Burst mode: Not supported
      Page mode: 4 word page
      Vpp Supply Minimum Program/Erase Voltage: 11.5 V
      Vpp Supply Maximum Program/Erase Voltage: 12.5 V
      Top/Bottom Boot Block: Uniform, Bottom WP
    RPX: CFI does not contain boot bank location. Assuming top.
    number of CFI chips: 1
    Using buffer write method
    cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
    Creating 6 MTD partitions on "RPX":
    0x00000000-0x00040000 : "bootstrap loader"
    mtd: Giving out device 0 to bootstrap loader
    0x00040000-0x00340000 : "kernel+ramdisk1"
    mtd: Giving out device 1 to kernel+ramdisk1
    0x00340000-0x00800000 : "application1"
    mtd: Giving out device 2 to application1
    0x00800000-0x00b00000 : "kernel+ramdisk2"
    mtd: Giving out device 3 to kernel+ramdisk2
    0x00b00000-0x00fc0000 : "application2"
    mtd: Giving out device 4 to application2
    0x00fc0000-0x01000000 : "diagnostics"
    mtd: Giving out device 5 to diagnostics

Fully tally of modules at this point
    
    # lsmod
    Module                  Size  Used by    Not tainted
    ep852-mtd               1452   0 (unused)
    cmdlinepart             2460   0 (unused)
    mtdpart                 6988   0 [ep852-mtd cmdlinepart]
    cfi_cmdset_0002        17916   1
    cfi_util                1184   0 [cfi_cmdset_0002]
    cfi_probe               3096   0
    gen_probe               2240   0 [cfi_probe]
    chipreg                 1344   0 [ep852-mtd cfi_probe]
    mtdchar                 6012   0 (unused)
    mtdcore                 4016   7 [ep852-mtd mtdpart mtdchar]

An attempt to get info from the chip works:
    
    # ./mtd_debug info /dev/mtd/0
    MTD_open
    MTD_ioctl
    MTD_ioctl
    mtd.type = MTD_NORFLASH
    mtd.flags = MTD_ERASEABLE
    mtd.size = 262144 (256K)
    mtd.erasesize = 131072 (128K)
    mtd.oobblock = 0
    mtd.oobsize = 0
    mtd.ecctype = MTD_ECC_NONE
    regions = 0

    MTD_close 1
    MTD_close 2
    cfi_amdstd_sync() 1
    cfi_amdstd_sync() 2
    cfi_amdstd_sync() 3
    cfi_amdstd_sync() 7
    cfi_amdstd_sync() 8
    cfi_amdstd_sync() 9
    MTD_close 3

An attempt to write the device fails. This is with this patch applied

    # cat > /dev/mtd/1
    MTD_open
    <i enter a newline>
    MTD_write
    MTD do_write_buffer(): WRITE 0x00040000(0x0a6c6962)
    map_read32 addr: c5068000
    map_read32 addr: c5068000
    map_read32 addr: c5068000
    map_read32 addr: c5068000
    MTD do_write_buffer(): software timeout
    cat: Write Error: Input/output error
    MTD_close 1
    MTD_close 2
    cfi_amdstd_sync() 1
    cfi_amdstd_sync() 2
    cfi_amdstd_sync() 3
    cfi_amdstd_sync() 7
    cfi_amdstd_sync() 8
    cfi_amdstd_sync() 9
    MTD_close 3

I'll keep bashing on it, but any wisdom would be appreciated...
tnx

--
Bob Coggeshall * Cogwheel, Inc * tel: (+1)206.230.6445 
cell: (+1)206.465.7355 fax: (+1)206.236.2553
icq: 233 433 536 
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-04-20 21:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-14 10:09 cfi_cmdset_0002.c (AMD interleaved chips) fix dkey
2004-04-14 10:25 ` David Vrabel
2004-04-14 23:29 ` Thayne Harbaugh
  -- strict thread matches above, loose matches on Subject: below --
2004-04-20 21:15 Bob Coggeshall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox