Lines Matching defs:flash
25 #include <linux/spi/flash.h>
67 static int sst25l_status(struct sst25l_flash *flash, int *status)
83 err = spi_sync(flash->spi, &m);
91 static int sst25l_write_enable(struct sst25l_flash *flash, int enable)
97 err = spi_write(flash->spi, command, 1);
102 err = spi_write(flash->spi, command, 1);
108 err = spi_write(flash->spi, command, 2);
113 err = sst25l_status(flash, &status);
123 static int sst25l_wait_till_ready(struct sst25l_flash *flash)
130 err = sst25l_status(flash, &status);
142 static int sst25l_erase_sector(struct sst25l_flash *flash, uint32_t offset)
147 err = sst25l_write_enable(flash, 1);
155 err = spi_write(flash->spi, command, 4);
159 err = sst25l_wait_till_ready(flash);
163 return sst25l_write_enable(flash, 0);
168 struct sst25l_flash *flash = to_sst25l_flash(mtd);
182 mutex_lock(&flash->lock);
184 err = sst25l_wait_till_ready(flash);
186 mutex_unlock(&flash->lock);
191 err = sst25l_erase_sector(flash, addr);
193 mutex_unlock(&flash->lock);
194 dev_err(&flash->spi->dev, "Erase failed\n");
201 mutex_unlock(&flash->lock);
209 struct sst25l_flash *flash = to_sst25l_flash(mtd);
231 mutex_lock(&flash->lock);
234 ret = sst25l_wait_till_ready(flash);
236 mutex_unlock(&flash->lock);
240 spi_sync(flash->spi, &message);
245 mutex_unlock(&flash->lock);
252 struct sst25l_flash *flash = to_sst25l_flash(mtd);
259 mutex_lock(&flash->lock);
261 ret = sst25l_write_enable(flash, 1);
266 ret = sst25l_wait_till_ready(flash);
276 ret = spi_write(flash->spi, command, 5);
287 ret = sst25l_wait_till_ready(flash);
292 ret = spi_write(flash->spi, command, 2);
299 ret = sst25l_write_enable(flash, 0);
304 mutex_unlock(&flash->lock);
351 struct sst25l_flash *flash;
359 flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL);
360 if (!flash)
363 flash->spi = spi;
364 mutex_init(&flash->lock);
365 spi_set_drvdata(spi, flash);
369 flash->mtd.name = data->name;
371 flash->mtd.dev.parent = &spi->dev;
372 flash->mtd.type = MTD_NORFLASH;
373 flash->mtd.flags = MTD_CAP_NORFLASH;
374 flash->mtd.erasesize = flash_info->erase_size;
375 flash->mtd.writesize = flash_info->page_size;
376 flash->mtd.writebufsize = flash_info->page_size;
377 flash->mtd.size = flash_info->page_size * flash_info->nr_pages;
378 flash->mtd._erase = sst25l_erase;
379 flash->mtd._read = sst25l_read;
380 flash->mtd._write = sst25l_write;
383 (long long)flash->mtd.size >> 10);
387 flash->mtd.name,
388 (long long)flash->mtd.size, (long long)(flash->mtd.size >> 20),
389 flash->mtd.erasesize, flash->mtd.erasesize / 1024,
390 flash->mtd.numeraseregions);
393 ret = mtd_device_register(&flash->mtd, data ? data->parts : NULL,
403 struct sst25l_flash *flash = spi_get_drvdata(spi);
405 return mtd_device_unregister(&flash->mtd);