mtd/drivers/mtd/chips cfi_cmdset_0002.c,1.80,1.81
jedec_probe.c,1.30,1.31
Thayne Harbaugh
tharbaugh at lnxi.com
Mon Sep 29 19:10:13 EDT 2003
Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv20788/drivers/mtd/chips
Modified Files:
cfi_cmdset_0002.c jedec_probe.c
Log Message:
- Make 'unsupported' messages more informative
- Don't reinitialize unlock addresses if they are alread setup
- Iterate through the list of unlock addresses instead of guessing
the addresses with seeds
Index: cfi_cmdset_0002.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0002.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- cfi_cmdset_0002.c 29 Sep 2003 16:50:01 -0000 1.80
+++ cfi_cmdset_0002.c 29 Sep 2003 23:10:10 -0000 1.81
@@ -233,30 +233,34 @@
}
}
/*
- * FIXME - These might already be setup (more correctly)
- * by jedec_probe.c.
+ * These might already be setup (more correctly) by
+ * jedec_probe.c - still need it for cfi_probe.c path.
*/
- switch (cfi->device_type) {
- case CFI_DEVICETYPE_X8:
- cfi->addr_unlock1 = 0x555;
- cfi->addr_unlock2 = 0x2aa;
- break;
- case CFI_DEVICETYPE_X16:
- cfi->addr_unlock1 = 0xaaa;
- if (map->buswidth == cfi->interleave) {
- /* X16 chip(s) in X8 mode */
- cfi->addr_unlock2 = 0x555;
- } else {
- cfi->addr_unlock2 = 0x554;
+ if ( ! (cfi->addr_unlock1 && cfi->addr_unlock2) ) {
+ switch (cfi->device_type) {
+ case CFI_DEVICETYPE_X8:
+ cfi->addr_unlock1 = 0x555;
+ cfi->addr_unlock2 = 0x2aa;
+ break;
+ case CFI_DEVICETYPE_X16:
+ cfi->addr_unlock1 = 0xaaa;
+ if (map->buswidth == cfi->interleave) {
+ /* X16 chip(s) in X8 mode */
+ cfi->addr_unlock2 = 0x555;
+ } else {
+ cfi->addr_unlock2 = 0x554;
+ }
+ break;
+ case CFI_DEVICETYPE_X32:
+ cfi->addr_unlock1 = 0x1555;
+ cfi->addr_unlock2 = 0xaaa;
+ break;
+ default:
+ printk(KERN_WARNING
+ "MTD %s(): Unsupported device type %d\n",
+ __func__, cfi->device_type);
+ return NULL;
}
- break;
- case CFI_DEVICETYPE_X32:
- cfi->addr_unlock1 = 0x1555;
- cfi->addr_unlock2 = 0xaaa;
- break;
- default:
- printk(KERN_NOTICE "Eep. Unknown cfi_cmdset_0002 device type %d\n", cfi->device_type);
- return NULL;
}
/* Install our own private info structure */
@@ -363,7 +367,8 @@
break;
default:
- printk(KERN_WARNING "Unsupported buswidth\n");
+ printk(KERN_WARNING "MTD %s(): Unsupported buswidth %d\n",
+ __func__, CFIDEV_BUSWIDTH);
goto setup_err;
break;
}
@@ -845,7 +850,9 @@
datum = *(__u64*)tmp_buf;
#endif
} else {
- return -EINVAL; /* should never happen, but be safe */
+ printk(KERN_WARNING "MTD %s(): Unsupported buswidth %d\n",
+ __func__, CFIDEV_BUSWIDTH);
+ return -EINVAL;
}
ret = do_write_oneword(map, &cfi->chips[chipnum],
@@ -887,6 +894,8 @@
datum = *(__u64*)buf;
#endif
} else {
+ printk(KERN_WARNING "MTD %s(): Unsupported buswidth %d\n",
+ __func__, CFIDEV_BUSWIDTH);
return -EINVAL;
}
ret = do_write_oneword(map, &cfi->chips[chipnum],
@@ -951,7 +960,9 @@
datum = *(__u64*)tmp_buf;
#endif
} else {
- return -EINVAL; /* should never happen, but be safe */
+ printk(KERN_WARNING "MTD %s(): Unsupported buswidth %d\n",
+ __func__, CFIDEV_BUSWIDTH);
+ return -EINVAL;
}
ret = do_write_oneword(map, &cfi->chips[chipnum],
Index: jedec_probe.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/jedec_probe.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- jedec_probe.c 29 Sep 2003 16:50:01 -0000 1.30
+++ jedec_probe.c 29 Sep 2003 23:10:11 -0000 1.31
@@ -1485,8 +1485,35 @@
u32 mfr, id;
__u8 uaddr;
- /* The ID's must match */
- if ( cfi->mfr != finfo->mfr_id || cfi->id != finfo->dev_id ) {
+ /*
+ * The IDs must match. For X16 and X32 devices operating in
+ * a lower width ( X8 or X16 ), the device ID's are usually just
+ * the lower byte(s) of the larger device ID for wider mode. If
+ * a part is found that doesn't fit this assumption (device id for
+ * smaller width mode is completely unrealated to full-width mode)
+ * then the jedec_table[] will have to be augmented with the IDs
+ * for different widths.
+ */
+ switch (cfi->device_type) {
+ case CFI_DEVICETYPE_X8:
+ mfr = (__u8)finfo->mfr_id;
+ id = (__u8)finfo->dev_id;
+ break;
+ case CFI_DEVICETYPE_X16:
+ mfr = (__u16)finfo->mfr_id;
+ id = (__u16)finfo->dev_id;
+ break;
+ case CFI_DEVICETYPE_X32:
+ mfr = (__u16)finfo->mfr_id;
+ id = (__u32)finfo->dev_id;
+ break;
+ default:
+ printk(KERN_WARNING
+ "MTD %s(): Unsupported device type %d\n",
+ __func__, cfi->device_type);
+ goto match_done;
+ }
+ if ( cfi->mfr != mfr || cfi->id != id ) {
goto match_done;
}
@@ -1567,38 +1594,19 @@
struct flchip *chips, struct cfi_private *cfi)
{
int i;
- int unlockpass = 0;
+ enum uaddr uaddr_idx = MTD_UADDR_NOT_SUPPORTED;
- /*
- * FIXME - eventually replace these unlock address seeds with
- * information from unlock_addrs[].
- */
+ retry:
if (!cfi->numchips) {
- switch (cfi->device_type) {
- case CFI_DEVICETYPE_X8:
- cfi->addr_unlock1 = 0x555;
- cfi->addr_unlock2 = 0x2aa;
- break;
- case CFI_DEVICETYPE_X16:
- cfi->addr_unlock1 = 0xaaa;
- if (map->buswidth == cfi->interleave) {
- /* X16 chip(s) in X8 mode */
- cfi->addr_unlock2 = 0x555;
- } else {
- cfi->addr_unlock2 = 0x554;
- }
- break;
- case CFI_DEVICETYPE_X32:
- cfi->addr_unlock1 = 0x1555;
- cfi->addr_unlock2 = 0xaaa;
- break;
- default:
- printk(KERN_NOTICE "Eep. Unknown jedec_probe device type %d\n", cfi->device_type);
- return 0;
- }
+ uaddr_idx++;
+
+ if (MTD_UADDR_UNNECESSARY == uaddr_idx)
+ return 0;
+
+ cfi->addr_unlock1 = unlock_addrs[uaddr_idx].addr1;
+ cfi->addr_unlock2 = unlock_addrs[uaddr_idx].addr2;
}
- retry:
/* Make certain we aren't probing past the end of map */
if (base >= map->size) {
printk(KERN_NOTICE
@@ -1652,16 +1660,7 @@
goto ok_out;
}
}
- switch(unlockpass++) {
- case 0:
- cfi->addr_unlock1 |= cfi->addr_unlock1 << 4;
- cfi->addr_unlock2 |= cfi->addr_unlock2 << 4;
- goto retry;
- case 1:
- cfi->addr_unlock1 = cfi->addr_unlock2 = 0;
- goto retry;
- }
- return 0;
+ goto retry;
} else {
__u16 mfr;
__u16 id;
More information about the linux-mtd-cvs
mailing list