--- zzzz-none-000/linux-2.6.13.1/drivers/mtd/chips/cfi_cmdset_0002.c 2005-09-10 02:42:58.000000000 +0000 +++ ohio-7170-487/linux-2.6.13.1/drivers/mtd/chips/cfi_cmdset_0002.c 2007-02-26 16:30:29.000000000 +0000 @@ -326,14 +326,12 @@ unsigned long offset = 0; int i,j; - printk(KERN_NOTICE "number of %s chips: %d\n", - (cfi->cfi_mode == CFI_MODE_CFI)?"CFI":"JEDEC",cfi->numchips); + printk(KERN_NOTICE "number of %s chips: %d\n", (cfi->cfi_mode == CFI_MODE_CFI)?"CFI":"JEDEC",cfi->numchips); /* Select the correct geometry setup */ 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); + mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) * mtd->numeraseregions, GFP_KERNEL); if (!mtd->eraseregions) { printk(KERN_WARNING "Failed to allocate memory for MTD erase region info\n"); goto setup_err; @@ -369,10 +367,6 @@ } #endif - /* FIXME: erase-suspend-program is broken. See - http://lists.infradead.org/pipermail/linux-mtd/2003-December/009001.html */ - printk(KERN_NOTICE "cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.\n"); - __module_get(THIS_MODULE); return mtd; @@ -434,13 +428,63 @@ map_word_equal(map, curd, expected); } -static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode) -{ +#if defined(DEBUG_CFI_FEATURES) +char *get_state(struct flchip *chip) { + switch (chip->state) { + case FL_STATUS: + return "FL_STATUS"; + case FL_READY: + return "FL_READY"; + case FL_CFI_QUERY: + return "FL_CFI_QUERY"; + case FL_JEDEC_QUERY: + return "FL_JEDEC_QUERY"; + case FL_ERASING: + return "FL_ERASING"; + case FL_XIP_WHILE_ERASING: + return "FL_XIP_WHILE_ERASING"; + case FL_POINT: + return "FL_POINT"; + default: + return "default"; + sleep: + return "sleep"; + } +} + +char *get_mode(int mode) { + + switch (mode) { + case FL_WRITING: + return "FL_WRITING"; + case FL_READY: + return "FL_READY"; + case FL_POINT: + return "FL_POINT"; + case FL_ERASING: + return "FL_ERASING"; + case FL_ERASE_SUSPENDING: + return "FL_ERASE_SUSPENDING"; + case FL_ERASE_SUSPENDED: + return "FL_ERASE_SUSPENDED"; + default: + printk("[get_mode] 0x%x", mode); + return ""; + } +} +#endif + +static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode) { DECLARE_WAITQUEUE(wait, current); struct cfi_private *cfi = map->fldrv_priv; unsigned long timeo; struct cfi_pri_amdstd *cfip = (struct cfi_pri_amdstd *)cfi->cmdset_priv; +#if defined(DEBUG_CFI_FEATURES) + if (chip->state != FL_READY) + printk("[get_chip] 0x%x state %s mode %s\n", adr, get_state(chip), get_mode(mode)); +#endif + resettime: timeo = jiffies + HZ; retry: @@ -485,6 +529,9 @@ /* Erase suspend */ /* It's harmless to issue the Erase-Suspend and Erase-Resume * commands when the erase algorithm isn't in progress. */ +#if defined(DEBUG_CFI_FEATURES) + printk("[get_chip] \n"); +#endif map_write(map, CMD(0xB0), chip->in_progress_block_addr); chip->oldstate = FL_ERASING; chip->state = FL_ERASE_SUSPENDING; @@ -1396,8 +1443,7 @@ return ret; } - DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): ERASE 0x%.8lx\n", - __func__, chip->start ); + DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): ERASE 0x%.8lx\n", __func__, chip->start ); XIP_INVAL_CACHED_RANGE(map, adr, map->size); ENABLE_VPP(map); @@ -1414,9 +1460,7 @@ chip->erase_suspended = 0; chip->in_progress_block_addr = adr; - INVALIDATE_CACHE_UDELAY(map, chip, - adr, map->size, - chip->erase_time*500); + INVALIDATE_CACHE_UDELAY(map, chip, adr, map->size, chip->erase_time*500); timeo = jiffies + (HZ*20); @@ -1432,8 +1476,10 @@ continue; } if (chip->erase_suspended) { - /* This erase was suspended and resumed. - Adjust the timeout */ +#if defined(DEBUG_CFI_FEATURES) + printk("[do_erase_chip] \n"); +#endif + /* This erase was suspended and resumed. Adjust the timeout */ timeo = jiffies + (HZ*20); /* FIXME */ chip->erase_suspended = 0; } @@ -1484,8 +1530,7 @@ return ret; } - DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): ERASE 0x%.8lx\n", - __func__, adr ); + DEBUG( MTD_DEBUG_LEVEL3, "MTD %s(): ERASE 0x%.8lx\n", __func__, adr ); XIP_INVAL_CACHED_RANGE(map, adr, len); ENABLE_VPP(map); @@ -1502,9 +1547,7 @@ chip->erase_suspended = 0; chip->in_progress_block_addr = adr; - INVALIDATE_CACHE_UDELAY(map, chip, - adr, len, - chip->erase_time*500); + INVALIDATE_CACHE_UDELAY(map, chip, adr, len, chip->erase_time*500); timeo = jiffies + (HZ*20); @@ -1520,8 +1563,10 @@ continue; } if (chip->erase_suspended) { - /* This erase was suspended and resumed. - Adjust the timeout */ +#if defined(DEBUG_CFI_FEATURES) + printk("[do_erase_oneblock] adr 0x%x\n", adr); +#endif + /* This erase was suspended and resumed. Adjust the timeout */ timeo = jiffies + (HZ*20); /* FIXME */ chip->erase_suspended = 0; } @@ -1533,8 +1578,7 @@ if (time_after(jiffies, timeo)) { xip_enable(map, chip, adr); - printk(KERN_WARNING "MTD %s(): software timeout\n", - __func__ ); + printk(KERN_WARNING "MTD %s(): software timeout\n", __func__ ); break; } @@ -1565,6 +1609,9 @@ ofs = instr->addr; len = instr->len; +#if defined(DEBUG_CFI_FEATURES) + printk("[cfi_amdstd_erase_varsize] 0x%x len 0x%x\n", ofs, len); +#endif ret = cfi_varsize_frob(mtd, do_erase_oneblock, ofs, len, NULL); if (ret) return ret; @@ -1667,6 +1714,9 @@ struct flchip *chip; int ret = 0; +#if defined(DEBUG_CFI_FEATURES) + printk("\n"); +#endif for (i=0; !ret && inumchips; i++) { chip = &cfi->chips[i]; @@ -1720,6 +1770,9 @@ int i; struct flchip *chip; +#if defined(DEBUG_CFI_FEATURES) + printk("\n"); +#endif for (i=0; inumchips; i++) { chip = &cfi->chips[i];