Lines Matching full:mtd

12 #include <mtd.h>
58 static void altera_qspi_get_locked_range(struct mtd_info *mtd, loff_t *ofs,
63 struct mtd_info *mtd = info->mtd; in flash_print_info() local
69 altera_qspi_get_locked_range(mtd, &ofs, &len); in flash_print_info()
85 struct mtd_info *mtd = info->mtd; in flash_erase() local
90 instr.mtd = mtd; in flash_erase()
91 instr.addr = mtd->erasesize * s_first; in flash_erase()
92 instr.len = mtd->erasesize * (s_last + 1 - s_first); in flash_erase()
94 ret = mtd_erase(mtd, &instr); in flash_erase()
105 struct mtd_info *mtd = info->mtd; in write_buff() local
106 struct udevice *dev = mtd->dev; in write_buff()
113 ret = mtd_write(mtd, to, cnt, &retlen, src); in write_buff()
124 /* probe every MTD device */ in flash_init()
133 static int altera_qspi_erase(struct mtd_info *mtd, struct erase_info *instr) in altera_qspi_erase() argument
135 struct udevice *dev = mtd->dev; in altera_qspi_erase()
146 addr &= ~(mtd->erasesize - 1); /* get lower aligned address */ in altera_qspi_erase()
157 last = pdata->base + addr + mtd->erasesize; in altera_qspi_erase()
165 sect = addr / mtd->erasesize; in altera_qspi_erase()
186 addr += mtd->erasesize; in altera_qspi_erase()
194 static int altera_qspi_read(struct mtd_info *mtd, loff_t from, size_t len, in altera_qspi_read() argument
197 struct udevice *dev = mtd->dev; in altera_qspi_read()
206 static int altera_qspi_write(struct mtd_info *mtd, loff_t to, size_t len, in altera_qspi_write() argument
209 struct udevice *dev = mtd->dev; in altera_qspi_write()
228 static void altera_qspi_sync(struct mtd_info *mtd) in altera_qspi_sync() argument
232 static void altera_qspi_get_locked_range(struct mtd_info *mtd, loff_t *ofs, in altera_qspi_get_locked_range() argument
235 struct udevice *dev = mtd->dev; in altera_qspi_get_locked_range()
247 *len = mtd->erasesize << (pow - 1); in altera_qspi_get_locked_range()
248 if (*len > mtd->size) in altera_qspi_get_locked_range()
249 *len = mtd->size; in altera_qspi_get_locked_range()
251 *ofs = mtd->size - *len; in altera_qspi_get_locked_range()
255 static int altera_qspi_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) in altera_qspi_lock() argument
257 struct udevice *dev = mtd->dev; in altera_qspi_lock()
266 num_sectors = mtd->size / mtd->erasesize; in altera_qspi_lock()
267 sector_start = ofs / mtd->erasesize; in altera_qspi_lock()
268 sector_end = (ofs + len) / mtd->erasesize; in altera_qspi_lock()
289 static int altera_qspi_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) in altera_qspi_unlock() argument
291 struct udevice *dev = mtd->dev; in altera_qspi_unlock()
308 struct mtd_info *mtd; in altera_qspi_probe() local
316 mtd = dev_get_uclass_priv(dev); in altera_qspi_probe()
317 mtd->dev = dev; in altera_qspi_probe()
318 mtd->name = "nor0"; in altera_qspi_probe()
319 mtd->type = MTD_NORFLASH; in altera_qspi_probe()
320 mtd->flags = MTD_CAP_NORFLASH; in altera_qspi_probe()
321 mtd->size = 1 << ((rdid & 0xff) - 6); in altera_qspi_probe()
322 mtd->writesize = 1; in altera_qspi_probe()
323 mtd->writebufsize = mtd->writesize; in altera_qspi_probe()
324 mtd->_erase = altera_qspi_erase; in altera_qspi_probe()
325 mtd->_read = altera_qspi_read; in altera_qspi_probe()
326 mtd->_write = altera_qspi_write; in altera_qspi_probe()
327 mtd->_sync = altera_qspi_sync; in altera_qspi_probe()
328 mtd->_lock = altera_qspi_lock; in altera_qspi_probe()
329 mtd->_unlock = altera_qspi_unlock; in altera_qspi_probe()
330 mtd->numeraseregions = 0; in altera_qspi_probe()
331 mtd->erasesize = 0x10000; in altera_qspi_probe()
332 if (add_mtd_device(mtd)) in altera_qspi_probe()
335 flash->mtd = mtd; in altera_qspi_probe()
336 flash->size = mtd->size; in altera_qspi_probe()
337 flash->sector_count = mtd->size / mtd->erasesize; in altera_qspi_probe()
341 flash->start[i] = flash->start[i - 1] + mtd->erasesize; in altera_qspi_probe()