Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: cfi_cmdset_0002: make sector erase command variable

Some old SST chips use 0x50 as sector erase command, instead
of 0x30. Make this value variable to handle such chips.

Signed-off-by: Guillaume LECERF <glecerf@gmail.com>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Guillaume LECERF and committed by
David Woodhouse
08968041 9fc05fca

+9 -4
+6 -4
drivers/mtd/chips/cfi_cmdset_0002.c
··· 291 291 292 292 cfi->addr_unlock1 = 0x555; 293 293 cfi->addr_unlock2 = 0x2AA; 294 + 295 + cfi->sector_erase_cmd = CMD(0x50); 294 296 } 295 297 296 298 static void fixup_sst38vf640x_sectorsize(struct mtd_info *mtd, void *param) ··· 693 691 * there was an error (so leave the erase 694 692 * routine to recover from it) or we trying to 695 693 * use the erase-in-progress sector. */ 696 - map_write(map, CMD(0x30), chip->in_progress_block_addr); 694 + map_write(map, cfi->sector_erase_cmd, chip->in_progress_block_addr); 697 695 chip->state = FL_ERASING; 698 696 chip->oldstate = FL_READY; 699 697 printk(KERN_ERR "MTD %s(): chip not ready after erase suspend\n", __func__); ··· 746 744 switch(chip->oldstate) { 747 745 case FL_ERASING: 748 746 chip->state = chip->oldstate; 749 - map_write(map, CMD(0x30), chip->in_progress_block_addr); 747 + map_write(map, cfi->sector_erase_cmd, chip->in_progress_block_addr); 750 748 chip->oldstate = FL_READY; 751 749 chip->state = FL_ERASING; 752 750 break; ··· 889 887 local_irq_disable(); 890 888 891 889 /* Resume the write or erase operation */ 892 - map_write(map, CMD(0x30), adr); 890 + map_write(map, cfi->sector_erase_cmd, adr); 893 891 chip->state = oldstate; 894 892 start = xip_currtime(); 895 893 } else if (usec >= 1000000/HZ) { ··· 1672 1670 cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1673 1671 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1674 1672 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 1675 - map_write(map, CMD(0x30), adr); 1673 + map_write(map, cfi->sector_erase_cmd, adr); 1676 1674 1677 1675 chip->state = FL_ERASING; 1678 1676 chip->erase_suspended = 0;
+2
drivers/mtd/chips/cfi_probe.c
··· 177 177 178 178 cfi->cfi_mode = CFI_MODE_CFI; 179 179 180 + cfi->sector_erase_cmd = CMD(0x30); 181 + 180 182 /* Read the CFI info structure */ 181 183 xip_disable_qry(base, map, cfi); 182 184 for (i=0; i<(sizeof(struct cfi_ident) + num_erase_regions * 4); i++)
+1
include/linux/mtd/cfi.h
··· 289 289 must be of the same type. */ 290 290 int mfr, id; 291 291 int numchips; 292 + map_word sector_erase_cmd; 292 293 unsigned long chipshift; /* Because they're of the same type */ 293 294 const char *im_name; /* inter_module name for cmdset_setup */ 294 295 struct flchip chips[0]; /* per-chip data structure for each chip */