• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/mtd/devices/

Lines Matching defs:flash

2  * MTD SPI driver for ST M25Pxx flash chips
26 #include <linux/spi/flash.h>
90 static int read_sr(struct m25p *flash)
96 retval = spi_write_then_read(flash->spi, &code, 1, &val, 1);
99 dev_err(&flash->spi->dev, "error %d reading SR\n",
112 static inline int write_enable(struct m25p *flash)
116 return spi_write_then_read(flash->spi, &code, 1, NULL, 0);
124 static int wait_till_ready(struct m25p *flash)
133 if ((sr = read_sr(flash)) < 0)
146 * Erase one sector of flash memory at offset ``offset'' which is any
151 static int erase_sector(struct m25p *flash, u32 offset)
153 DEBUG(MTD_DEBUG_LEVEL3, "%s: %s at 0x%08x\n", flash->spi->dev.bus_id,
157 if (wait_till_ready(flash))
161 write_enable(flash);
164 flash->command[0] = OPCODE_SE;
165 flash->command[1] = offset >> 16;
166 flash->command[2] = offset >> 8;
167 flash->command[3] = offset;
169 spi_write(flash->spi, flash->command, sizeof(flash->command));
181 * Erase an address range on the flash chip. The address range may extend
186 struct m25p *flash = mtd_to_m25p(mtd);
190 flash->spi->dev.bus_id, __FUNCTION__, "at",
194 if (instr->addr + instr->len > flash->mtd.size)
204 down(&flash->lock);
208 if (erase_sector(flash, addr)) {
210 up(&flash->lock);
218 up(&flash->lock);
227 * Read an address range from the flash chip. The address range
233 struct m25p *flash = mtd_to_m25p(mtd);
238 flash->spi->dev.bus_id, __FUNCTION__, "from",
245 if (from + len > flash->mtd.size)
251 t[0].tx_buf = flash->command;
252 t[0].len = sizeof(flash->command);
263 down(&flash->lock);
266 if (wait_till_ready(flash)) {
268 up(&flash->lock);
275 flash->command[0] = OPCODE_READ;
276 flash->command[1] = from >> 16;
277 flash->command[2] = from >> 8;
278 flash->command[3] = from;
280 spi_sync(flash->spi, &m);
282 *retlen = m.actual_length - sizeof(flash->command);
284 up(&flash->lock);
290 * Write an address range to the flash chip. Data must be written in
297 struct m25p *flash = mtd_to_m25p(mtd);
303 flash->spi->dev.bus_id, __FUNCTION__, "to",
313 if (to + len > flash->mtd.size)
319 t[0].tx_buf = flash->command;
320 t[0].len = sizeof(flash->command);
326 down(&flash->lock);
329 if (wait_till_ready(flash))
332 write_enable(flash);
335 flash->command[0] = OPCODE_PP;
336 flash->command[1] = to >> 16;
337 flash->command[2] = to >> 8;
338 flash->command[3] = to;
347 spi_sync(flash->spi, &m);
349 *retlen = m.actual_length - sizeof(flash->command);
357 spi_sync(flash->spi, &m);
359 *retlen = m.actual_length - sizeof(flash->command);
367 /* write the next page to flash */
368 flash->command[1] = (to + i) >> 16;
369 flash->command[2] = (to + i) >> 8;
370 flash->command[3] = (to + i);
375 wait_till_ready(flash);
377 write_enable(flash);
379 spi_sync(flash->spi, &m);
383 - sizeof(flash->command);
387 up(&flash->lock);
427 struct m25p *flash;
451 flash = kzalloc(sizeof *flash, GFP_KERNEL);
452 if (!flash)
455 flash->spi = spi;
456 init_MUTEX(&flash->lock);
457 dev_set_drvdata(&spi->dev, flash);
460 flash->mtd.name = data->name;
462 flash->mtd.name = spi->dev.bus_id;
464 flash->mtd.type = MTD_NORFLASH;
465 flash->mtd.writesize = 1;
466 flash->mtd.flags = MTD_CAP_NORFLASH;
467 flash->mtd.size = info->sector_size * info->n_sectors;
468 flash->mtd.erasesize = info->sector_size;
469 flash->mtd.erase = m25p80_erase;
470 flash->mtd.read = m25p80_read;
471 flash->mtd.write = m25p80_write;
474 flash->mtd.size / 1024);
479 flash->mtd.name,
480 flash->mtd.size, flash->mtd.size / (1024*1024),
481 flash->mtd.erasesize, flash->mtd.erasesize / 1024,
482 flash->mtd.numeraseregions);
484 if (flash->mtd.numeraseregions)
485 for (i = 0; i < flash->mtd.numeraseregions; i++)
490 i, flash->mtd.eraseregions[i].offset,
491 flash->mtd.eraseregions[i].erasesize,
492 flash->mtd.eraseregions[i].erasesize / 1024,
493 flash->mtd.eraseregions[i].numblocks);
506 nr_parts = parse_mtd_partitions(&flash->mtd,
525 flash->partitioned = 1;
526 return add_mtd_partitions(&flash->mtd, parts, nr_parts);
532 return add_mtd_device(&flash->mtd) == 1 ? -ENODEV : 0;
538 struct m25p *flash = dev_get_drvdata(&spi->dev);
542 if (mtd_has_partitions() && flash->partitioned)
543 status = del_mtd_partitions(&flash->mtd);
545 status = del_mtd_device(&flash->mtd);
547 kfree(flash);
580 MODULE_DESCRIPTION("MTD SPI driver for ST M25Pxx flash chips");