[spi-devel-general] [PATCH] SST25L (non JEDEC) SPI Flash driver

Ryan Mallon ryan at bluewatersys.com
Wed Jun 24 22:52:58 EDT 2009


H Hartley Sweeten wrote:
> On Wednesday, June 24, 2009 7:06 PM, Ryan Mallon wrote:
>> H Hartley Sweeten wrote:
>>> On Sunday, June 21, 2009 8:59 PM, Ryan Mallon wrote:

> I think you could still support the block erase and chip erase internal
> to the driver for performance.  Maybe something like the following?
> 
> static int sst25l_erase(struct mtd_info *mtd, struct erase_info *instr)
> {
...
> 	if (instr->len == mtd->size) {
> 		err = __sst25l_erase(flash, addr, SST25L_CMD_CHIP_ERASE);
> 		if (err) {
> 			mutex_unlock(&flash->lock);
> 			instr->state = MTD_ERASE_FAILED;
> 			dev_err(&flash->spi->dev, "Erase failed\n");
> 			return err;
> 		}
> 	} else {
> 		while (addr < end) {
> 			u32 erasesize;
> 
> 			if (addr % block || addr + block > end) {
> 				erasesize = sector;
> 				err = __sst25l_erase(flash, addr,
> 						SST25L_CMD_SECTOR_ERASE);
> 			} else {
> 				erasesize = block;
> 				err = __sst25l_erase(flash, addr,
> 						SST25L_CMD_BLOCK_ERASE);
> 			}
> 			if (err) {
> 				mutex_unlock(&flash->lock);
> 				instr->state = MTD_ERASE_FAILED;
> 				dev_err(&flash->spi->dev, "Erase failed\n");
> 				return err;
> 			}
> 
> 			addr += erasesize;
> 		}
> 	}

> 
> You would need to add sector_size and block_size to the ss25l_flash
> and flash_info structs and modify flash_info as appropriate.  Then copy
> those over during the probe and use sector_size for mtd.erasesize.
> 
> That way we get the 4K erase size but still get the performance increase
> for block and chip erase.

We discussed this, but it adds additional complexity to what is
otherwise quite a simple driver. The 4K sector erase will work in all
cases, and the speed difference shouldn't be a massive problem. I would
venture a guess that most people using the chips have reasonably
non-volatile storage on them, and don't get erased very often. We use
ours for the Bootloader and boot environment.

~Ryan

-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

       Ryan Mallon                              Unit 5, Amuri Park
       Phone: +64 3 3779127                     404 Barbadoes St
       Fax:   +64 3 3779135                     PO Box 13 889
       Email: ryan at bluewatersys.com             Christchurch, 8013
       Web:   http://www.bluewatersys.com       New Zealand
       Freecall Australia  1800 148 751         USA 1800 261 2934



More information about the linux-mtd mailing list