• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/mtd/onenand/

Lines Matching refs:this

162  * @param this		onenand chip data structure
168 static int onenand_block_address(struct onenand_chip *this, int block)
171 if (block & this->density_mask)
172 return ONENAND_DDP_CHIP1 | (block ^ this->density_mask);
179 * @param this onenand chip data structure
185 static int onenand_bufferram_address(struct onenand_chip *this, int block)
188 if (block & this->density_mask)
242 * @param this - OneNAND device structure
245 static unsigned flexonenand_block(struct onenand_chip *this, loff_t addr)
249 if (ONENAND_IS_DDP(this) && addr >= this->diesize[0]) {
251 addr -= this->diesize[0];
254 boundary = this->boundary[die];
256 blk = addr >> (this->erase_shift - 1);
260 blk += die ? this->density_mask : 0;
264 inline unsigned onenand_block(struct onenand_chip *this, loff_t addr)
266 if (!FLEXONENAND(this))
267 return addr >> this->erase_shift;
268 return flexonenand_block(this, addr);
273 * @this: OneNAND device structure
278 static loff_t flexonenand_addr(struct onenand_chip *this, int block)
283 if (ONENAND_IS_DDP(this) && block >= this->density_mask) {
284 block -= this->density_mask;
286 ofs = this->diesize[0];
289 boundary = this->boundary[die];
290 ofs += (loff_t)block << (this->erase_shift - 1);
292 ofs += (loff_t)(block - boundary - 1) << (this->erase_shift - 1);
296 loff_t onenand_addr(struct onenand_chip *this, int block)
298 if (!FLEXONENAND(this))
299 return (loff_t)block << this->erase_shift;
300 return flexonenand_addr(this, block);
344 struct onenand_chip *this = mtd->priv;
359 block = addr * this->density_mask;
368 block = onenand_block(this, addr);
374 block = addr * this->density_mask;
379 block = onenand_block(this, addr);
380 if (FLEXONENAND(this))
381 page = (int) (addr - onenand_addr(this, block))>>\
382 this->page_shift;
384 page = (int) (addr >> this->page_shift);
385 if (ONENAND_IS_2PLANE(this)) {
389 if (addr & this->writesize)
393 page &= this->page_mask;
400 value = onenand_bufferram_address(this, block);
401 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
403 if (ONENAND_IS_MLC(this) || ONENAND_IS_2PLANE(this) ||
404 ONENAND_IS_4KB_PAGE(this))
406 ONENAND_SET_BUFFERRAM0(this);
409 ONENAND_SET_NEXT_BUFFERRAM(this);
416 value = onenand_block_address(this, block);
417 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
420 value = onenand_bufferram_address(this, block);
421 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
433 if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this))
435 dataram = ONENAND_SET_BUFFERRAM0(this);
437 dataram = ONENAND_SET_NEXT_BUFFERRAM(this);
441 if (ONENAND_IS_2PLANE(this) && cmd == ONENAND_CMD_PROG)
443 dataram = ONENAND_CURRENT_BUFFERRAM(this);
449 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS8);
453 this->write_word(value, this->base + ONENAND_REG_START_BUFFER);
457 this->write_word(ONENAND_INT_CLEAR, this->base + ONENAND_REG_INTERRUPT);
460 this->write_word(cmd, this->base + ONENAND_REG_COMMAND);
467 * @param this onenand chip structure
469 static inline int onenand_read_ecc(struct onenand_chip *this)
473 if (!FLEXONENAND(this) && !ONENAND_IS_4KB_PAGE(this))
474 return this->read_word(this->base + ONENAND_REG_ECC_STATUS);
477 ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS + i*2);
500 struct onenand_chip * this = mtd->priv;
509 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
518 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
520 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
528 int ecc = onenand_read_ecc(this);
580 struct onenand_chip *this = data;
583 if (!this->complete.done)
584 complete(&this->complete);
598 struct onenand_chip *this = mtd->priv;
600 wait_for_completion(&this->complete);
614 struct onenand_chip *this = mtd->priv;
618 this->wait = onenand_interrupt_wait;
621 remain = wait_for_completion_timeout(&this->complete, timeout);
627 free_irq(this->irq, this);
629 this->wait = onenand_wait;
645 struct onenand_chip *this = mtd->priv;
648 init_completion(&this->complete);
650 if (this->irq <= 0) {
651 this->wait = onenand_wait;
655 if (request_irq(this->irq, &onenand_interrupt,
656 IRQF_SHARED, "onenand", this)) {
658 this->wait = onenand_wait;
663 syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
665 this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
667 this->wait = onenand_try_interrupt_wait;
680 struct onenand_chip *this = mtd->priv;
682 if (ONENAND_CURRENT_BUFFERRAM(this)) {
683 /* Note: the 'this->writesize' is a real page size */
685 return this->writesize;
706 struct onenand_chip *this = mtd->priv;
709 bufferram = this->base + area;
720 word = this->read_word(bufferram + offset + count);
742 struct onenand_chip *this = mtd->priv;
745 bufferram = this->base + area;
749 this->mmcontrol(mtd, ONENAND_SYS_CFG1_SYNC_READ);
758 word = this->read_word(bufferram + offset + count);
764 this->mmcontrol(mtd, 0);
782 struct onenand_chip *this = mtd->priv;
785 bufferram = this->base + area;
800 word = this->read_word(bufferram + byte_offset);
802 this->write_word(word, bufferram + byte_offset);
820 struct onenand_chip *this = mtd->priv;
824 block = (int) (addr >> this->erase_shift) & ~1;
826 if (addr & this->writesize)
828 page = (int) (addr >> (this->page_shift + 1)) & this->page_mask;
844 struct onenand_chip *this = mtd->priv;
848 if (ONENAND_IS_2PLANE(this))
851 blockpage = (int) (addr >> this->page_shift);
854 i = ONENAND_CURRENT_BUFFERRAM(this);
855 if (this->bufferram[i].blockpage == blockpage)
859 i = ONENAND_NEXT_BUFFERRAM(this);
860 if (this->bufferram[i].blockpage == blockpage) {
861 ONENAND_SET_NEXT_BUFFERRAM(this);
866 if (found && ONENAND_IS_DDP(this)) {
868 int block = onenand_block(this, addr);
869 int value = onenand_bufferram_address(this, block);
870 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
887 struct onenand_chip *this = mtd->priv;
891 if (ONENAND_IS_2PLANE(this))
894 blockpage = (int) (addr >> this->page_shift);
897 i = ONENAND_NEXT_BUFFERRAM(this);
898 if (this->bufferram[i].blockpage == blockpage)
899 this->bufferram[i].blockpage = -1;
902 i = ONENAND_CURRENT_BUFFERRAM(this);
904 this->bufferram[i].blockpage = blockpage;
906 this->bufferram[i].blockpage = -1;
920 struct onenand_chip *this = mtd->priv;
926 loff_t buf_addr = this->bufferram[i].blockpage << this->page_shift;
928 this->bufferram[i].blockpage = -1;
941 struct onenand_chip *this = mtd->priv;
948 spin_lock(&this->chip_lock);
949 if (this->state == FL_READY) {
950 this->state = new_state;
951 spin_unlock(&this->chip_lock);
955 spin_unlock(&this->chip_lock);
956 return (this->state == FL_PM_SUSPENDED) ? 0 : -EAGAIN;
959 add_wait_queue(&this->wq, &wait);
960 spin_unlock(&this->chip_lock);
962 remove_wait_queue(&this->wq, &wait);
976 struct onenand_chip *this = mtd->priv;
979 spin_lock(&this->chip_lock);
980 this->state = FL_READY;
981 wake_up(&this->wq);
982 spin_unlock(&this->chip_lock);
995 struct onenand_chip *this = mtd->priv;
1001 uint8_t *oob_buf = this->oob_buf;
1003 free = this->ecclayout->oobfree;
1011 this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize);
1012 free = this->ecclayout->oobfree;
1042 struct onenand_chip *this = mtd->priv;
1046 if (!FLEXONENAND(this))
1055 if (mtd->eraseregions[i].erasesize < (1 << this->erase_shift))
1066 this->command(mtd, FLEXONENAND_CMD_RECOVER_LSB, addr, this->writesize);
1067 return this->wait(mtd, FL_READING);
1082 struct onenand_chip *this = mtd->priv;
1091 int writesize = this->writesize;
1097 oobsize = this->ecclayout->oobavail;
1124 this->command(mtd, ONENAND_CMD_READ, from, writesize);
1126 ret = this->wait(mtd, FL_READING);
1134 this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);
1142 this->read_bufferram(mtd, ONENAND_SPARERAM, oobbuf, oobcolumn, thisooblen);
1184 struct onenand_chip *this = mtd->priv;
1193 int writesize = this->writesize;
1199 oobsize = this->ecclayout->oobavail;
1221 this->command(mtd, ONENAND_CMD_READ, from, writesize);
1222 ret = this->wait(mtd, FL_READING);
1238 this->command(mtd, ONENAND_CMD_READ, from, writesize);
1244 if (ONENAND_IS_DDP(this) &&
1245 unlikely(from == (this->chipsize >> 1))) {
1246 this->write_word(ONENAND_DDP_CHIP0, this->base + ONENAND_REG_START_ADDRESS2);
1250 ONENAND_SET_PREV_BUFFERRAM(this);
1253 this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);
1263 this->read_bufferram(mtd, ONENAND_SPARERAM, oobbuf, oobcolumn, thisooblen);
1275 this->write_word(ONENAND_DDP_CHIP1, this->base + ONENAND_REG_START_ADDRESS2);
1276 ONENAND_SET_NEXT_BUFFERRAM(this);
1282 ret = this->wait(mtd, FL_READING);
1316 struct onenand_chip *this = mtd->priv;
1333 oobsize = this->ecclayout->oobavail;
1347 column + len > ((mtd->size >> this->page_shift) -
1348 (from >> this->page_shift)) * oobsize)) {
1356 readcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1364 this->command(mtd, readcmd, from, mtd->oobsize);
1368 ret = this->wait(mtd, FL_READING);
1381 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen);
1422 struct onenand_chip *this = mtd->priv;
1432 ret = ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this) ?
1452 struct onenand_chip *this = mtd->priv;
1467 ret = ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this) ?
1486 struct onenand_chip *this = mtd->priv;
1494 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
1499 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
1500 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
1503 int ecc = onenand_read_ecc(this);
1537 struct onenand_chip *this = mtd->priv;
1561 readcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1569 this->command(mtd, readcmd, from, mtd->oobsize);
1573 ret = this->bbt_wait(mtd, FL_READING);
1580 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen);
1590 from += this->writesize;
1611 struct onenand_chip *this = mtd->priv;
1612 u_char *oob_buf = this->oob_buf;
1615 readcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1617 this->command(mtd, readcmd, to, mtd->oobsize);
1619 status = this->wait(mtd, FL_READING);
1623 this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize);
1640 struct onenand_chip *this = mtd->priv;
1645 thislen = min_t(int, this->writesize, len);
1646 column = addr & (this->writesize - 1);
1647 if (column + thislen > this->writesize)
1648 thislen = this->writesize - column;
1650 this->command(mtd, ONENAND_CMD_READ, addr, this->writesize);
1654 ret = this->wait(mtd, FL_READING);
1660 this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize);
1662 if (memcmp(buf, this->verify_buf, thislen))
1677 #define NOTALIGNED(x) ((x & (this->subpagesize - 1)) != 0)
1681 struct onenand_chip *this = mtd->priv;
1686 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
1706 struct onenand_chip *this = mtd->priv;
1711 if (this->state == FL_PM_SUSPENDED)
1744 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen);
1749 memset(this->page_buf, 0xff, mtd->writesize);
1750 memcpy(this->page_buf + column, buf, thislen);
1751 wbuf = this->page_buf;
1754 this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize);
1755 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
1757 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
1763 if (ONENAND_IS_2PLANE(this)) {
1764 ONENAND_SET_BUFFERRAM1(this);
1765 onenand_update_bufferram(mtd, to + this->writesize, !ret && !subpage);
1798 struct onenand_chip *this = mtd->priv;
1805 free = this->ecclayout->oobfree;
1813 free = this->ecclayout->oobfree;
1839 struct onenand_chip *this = mtd->priv;
1876 oobsize = this->ecclayout->oobavail;
1894 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen);
1899 memset(this->page_buf, 0xff, mtd->writesize);
1900 memcpy(this->page_buf + column, buf, thislen);
1901 wbuf = this->page_buf;
1904 this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize);
1907 oobbuf = this->oob_buf;
1923 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize);
1925 ONENAND_SET_NEXT_BUFFERRAM(this);
1931 if (!ONENAND_IS_2PLANE(this) && !ONENAND_IS_4KB_PAGE(this) && !first) {
1932 ONENAND_SET_PREV_BUFFERRAM(this);
1934 ret = this->wait(mtd, FL_WRITING);
1954 ONENAND_SET_NEXT_BUFFERRAM(this);
1957 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
1962 if (ONENAND_IS_2PLANE(this) || ONENAND_IS_4KB_PAGE(this)) {
1963 ret = this->wait(mtd, FL_WRITING);
2023 struct onenand_chip *this = mtd->priv;
2040 oobsize = this->ecclayout->oobavail;
2061 column + len > ((mtd->size >> this->page_shift) -
2062 (to >> this->page_shift)) * oobsize)) {
2068 oobbuf = this->oob_buf;
2070 oobcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_PROG : ONENAND_CMD_PROGOOB;
2078 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobsize);
2087 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize);
2089 if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this)) {
2091 memset(this->page_buf, 0xff, mtd->writesize);
2092 this->write_bufferram(mtd, ONENAND_DATARAM,
2093 this->page_buf, 0, mtd->writesize);
2096 this->command(mtd, oobcmd, to, mtd->oobsize);
2099 if (ONENAND_IS_2PLANE(this)) {
2100 ONENAND_SET_BUFFERRAM1(this);
2101 onenand_update_bufferram(mtd, to + this->writesize, 0);
2104 ret = this->wait(mtd, FL_WRITING);
2202 struct onenand_chip *this = mtd->priv;
2203 struct bbm_info *bbm = this->bbm;
2213 struct onenand_chip *this = mtd->priv;
2216 unsigned int block_size = (1 << this->erase_shift);
2220 this->command(mtd, ONENAND_CMD_ERASE_VERIFY, addr, block_size);
2221 ret = this->wait(mtd, FL_VERIFYING_ERASE);
2224 __func__, onenand_block(this, addr));
2247 struct onenand_chip *this = mtd->priv;
2256 if (ONENAND_IS_DDP(this)) {
2257 loff_t bdry_addr = this->chipsize >> 1;
2259 bdry_block = bdry_addr >> this->erase_shift;
2289 int this_block = (addr >> this->erase_shift);
2300 this->command(mtd, ONENAND_CMD_MULTIBLOCK_ERASE,
2304 ret = this->wait(mtd, FL_PREPARING_ERASE);
2308 onenand_block(this, addr));
2321 this->command(mtd, ONENAND_CMD_ERASE, addr, block_size);
2324 ret = this->wait(mtd, FL_ERASING);
2328 __func__, onenand_block(this, addr));
2365 struct onenand_chip *this = mtd->priv;
2391 this->command(mtd, ONENAND_CMD_ERASE, addr, block_size);
2395 ret = this->wait(mtd, FL_ERASING);
2399 __func__, onenand_block(this, addr));
2435 struct onenand_chip *this = mtd->priv;
2452 if (FLEXONENAND(this)) {
2453 /* Find the eraseregion of this address */
2464 block_size = 1 << this->erase_shift;
2551 struct onenand_chip *this = mtd->priv;
2552 struct bbm_info *bbm = this->bbm;
2563 block = onenand_block(this, ofs);
2581 struct onenand_chip *this = mtd->priv;
2593 ret = this->block_markbad(mtd, ofs);
2609 struct onenand_chip *this = mtd->priv;
2613 start = onenand_block(this, ofs);
2614 end = onenand_block(this, ofs + len) - 1;
2622 if (this->options & ONENAND_HAS_CONT_LOCK) {
2624 this->write_word(start, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2626 this->write_word(end, this->base + ONENAND_REG_END_BLOCK_ADDRESS);
2628 this->command(mtd, cmd, 0, 0);
2631 this->wait(mtd, FL_LOCKING);
2634 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
2639 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
2650 value = onenand_block_address(this, block);
2651 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
2653 value = onenand_bufferram_address(this, block);
2654 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
2656 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2658 this->command(mtd, cmd, 0, 0);
2661 this->wait(mtd, FL_LOCKING);
2664 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
2669 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
2716 * @param this onenand chip data structure
2720 static int onenand_check_lock_status(struct onenand_chip *this)
2725 end = this->chipsize >> this->erase_shift;
2728 value = onenand_block_address(this, block);
2729 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
2731 value = onenand_bufferram_address(this, block);
2732 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
2734 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2737 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
2756 struct onenand_chip *this = mtd->priv;
2760 if (this->options & ONENAND_HAS_UNLOCK_ALL) {
2762 this->write_word(0, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2764 this->command(mtd, ONENAND_CMD_UNLOCK_ALL, 0, 0);
2767 this->wait(mtd, FL_LOCKING);
2770 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
2775 if (this->options & ONENAND_SKIP_UNLOCK_CHECK)
2779 if (onenand_check_lock_status(this))
2782 if (ONENAND_IS_DDP(this) && !FLEXONENAND(this)) {
2784 ofs = this->chipsize >> 1;
2785 len = this->chipsize >> 1;
2804 struct onenand_chip *this = mtd->priv;
2810 block = (int) (addr >> this->erase_shift);
2815 block = (int) (addr >> this->erase_shift);
2816 page = (int) (addr >> this->page_shift);
2818 if (ONENAND_IS_2PLANE(this)) {
2822 if (addr & this->writesize)
2826 page &= this->page_mask;
2832 value = onenand_block_address(this, block);
2833 this->write_word(value, this->base +
2844 if (ONENAND_IS_2PLANE(this) && cmd == ONENAND_CMD_PROG)
2846 dataram = ONENAND_CURRENT_BUFFERRAM(this);
2852 this->write_word(value, this->base +
2857 this->write_word(value, this->base + ONENAND_REG_START_BUFFER);
2861 this->write_word(ONENAND_INT_CLEAR, this->base + ONENAND_REG_INTERRUPT);
2864 this->write_word(cmd, this->base + ONENAND_REG_COMMAND);
2882 struct onenand_chip *this = mtd->priv;
2899 oobbuf = this->oob_buf;
2907 block = (int) (to >> this->erase_shift);
2913 value = onenand_block_address(this, block);
2914 this->write_word(value, this->base +
2922 value = onenand_bufferram_address(this, block);
2923 this->write_word(value, this->base +
2925 ONENAND_SET_NEXT_BUFFERRAM(this);
2930 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
2931 this->wait(mtd, FL_OTPING);
2943 this->write_bufferram(mtd, ONENAND_SPARERAM,
2948 if (ONENAND_IS_2PLANE(this)) {
2949 ONENAND_SET_BUFFERRAM1(this);
2950 onenand_update_bufferram(mtd, to + this->writesize, 0);
2953 ret = this->wait(mtd, FL_WRITING);
2960 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2961 this->wait(mtd, FL_RESETING);
2963 status = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
3013 struct onenand_chip *this = mtd->priv;
3023 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
3024 this->wait(mtd, FL_OTPING);
3026 ret = ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this) ?
3031 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3032 this->wait(mtd, FL_RESETING);
3050 struct onenand_chip *this = mtd->priv;
3057 memcpy(this->page_buf, buf, len);
3058 memset(this->page_buf + len, 0xff, mtd->writesize - len);
3059 pbuf = this->page_buf;
3064 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
3065 this->wait(mtd, FL_OTPING);
3075 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3076 this->wait(mtd, FL_RESETING);
3094 struct onenand_chip *this = mtd->priv;
3098 if (FLEXONENAND(this)) {
3101 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
3102 this->wait(mtd, FL_OTPING);
3115 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3116 this->wait(mtd, FL_RESETING);
3145 struct onenand_chip *this = mtd->priv;
3152 density = onenand_get_density(this->device_id);
3307 struct onenand_chip *this = mtd->priv;
3308 u_char *buf = FLEXONENAND(this) ? this->page_buf : this->oob_buf;
3313 memset(buf, 0xff, FLEXONENAND(this) ? this->writesize
3323 len = FLEXONENAND(this) ? mtd->writesize : 16;
3331 if (FLEXONENAND(this))
3361 struct onenand_chip *this = mtd->priv;
3365 density = onenand_get_density(this->device_id);
3366 process = this->version_id >> ONENAND_VERSION_PROCESS_SHIFT;
3371 if (ONENAND_IS_DDP(this))
3372 this->options |= ONENAND_HAS_2PLANE;
3374 this->options |= ONENAND_HAS_4KB_PAGE;
3378 if (!ONENAND_IS_DDP(this))
3379 this->options |= ONENAND_HAS_2PLANE;
3380 this->options |= ONENAND_HAS_UNLOCK_ALL;
3385 this->options |= ONENAND_HAS_UNLOCK_ALL;
3391 this->options |= ONENAND_HAS_CONT_LOCK;
3395 if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this))
3396 this->options &= ~ONENAND_HAS_2PLANE;
3398 if (FLEXONENAND(this)) {
3399 this->options &= ~ONENAND_HAS_CONT_LOCK;
3400 this->options |= ONENAND_HAS_UNLOCK_ALL;
3403 if (this->options & ONENAND_HAS_CONT_LOCK)
3405 if (this->options & ONENAND_HAS_UNLOCK_ALL)
3407 if (this->options & ONENAND_HAS_2PLANE)
3409 if (this->options & ONENAND_HAS_4KB_PAGE)
3476 struct onenand_chip *this = mtd->priv;
3481 syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
3482 this->write_word((syscfg | 0x0100), this->base + ONENAND_REG_SYS_CFG1);
3484 for (die = 0; die < this->dies; die++) {
3485 this->command(mtd, FLEXONENAND_CMD_PI_ACCESS, die, 0);
3486 this->wait(mtd, FL_SYNCING);
3488 this->command(mtd, FLEXONENAND_CMD_READ_PI, die, 0);
3489 ret = this->wait(mtd, FL_READING);
3491 bdry = this->read_word(this->base + ONENAND_DATARAM);
3496 this->boundary[die] = bdry & FLEXONENAND_PI_MASK;
3498 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3499 ret = this->wait(mtd, FL_RESETING);
3502 this->boundary[die], locked ? "(Locked)" : "(Unlocked)");
3506 this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
3517 struct onenand_chip *this = mtd->priv;
3522 density = onenand_get_density(this->device_id);
3523 blksperdie = ((loff_t)(16 << density) << 20) >> (this->erase_shift);
3524 blksperdie >>= ONENAND_IS_DDP(this) ? 1 : 0;
3526 eraseshift = this->erase_shift - 1;
3528 mtd->numeraseregions = this->dies << 1;
3534 for (; die < this->dies; die++) {
3535 if (!die || this->boundary[die-1] != maxbdry) {
3540 this->boundary[die] + 1;
3546 this->boundary[die] + 1;
3547 ofs += (this->boundary[die] + 1) << (eraseshift - 1);
3549 if (this->boundary[die] != maxbdry) {
3554 this->boundary[die];
3562 mtd->erasesize = 1 << this->erase_shift;
3574 for (die = 0, mtd->size = 0; die < this->dies; die++) {
3575 this->diesize[die] = (loff_t)blksperdie << this->erase_shift;
3576 this->diesize[die] -= (loff_t)(this->boundary[die] + 1)
3577 << (this->erase_shift - 1);
3578 mtd->size += this->diesize[die];
3593 * Avoid this by ensuring that the block to be converted is
3598 struct onenand_chip *this = mtd->priv;
3606 .oobbuf = this->oob_buf,
3613 addr = flexonenand_addr(this, block);
3626 if (this->oob_buf[i] != 0xff)
3646 struct onenand_chip *this = mtd->priv;
3651 if (die && (!ONENAND_IS_DDP(this)))
3655 if (boundary < 0 || boundary == this->boundary[die])
3658 density = onenand_get_density(this->device_id);
3659 blksperdie = ((16 << density) << 20) >> this->erase_shift;
3660 blksperdie >>= ONENAND_IS_DDP(this) ? 1 : 0;
3669 old = this->boundary[die] + (die * this->density_mask);
3670 new = boundary + (die * this->density_mask);
3678 this->command(mtd, FLEXONENAND_CMD_PI_ACCESS, die, 0);
3679 this->wait(mtd, FL_SYNCING);
3682 this->command(mtd, FLEXONENAND_CMD_READ_PI, die, 0);
3683 ret = this->wait(mtd, FL_READING);
3685 thisboundary = this->read_word(this->base + ONENAND_DATARAM);
3695 addr = die ? this->diesize[0] : 0;
3700 this->command(mtd, ONENAND_CMD_ERASE, addr, 0);
3701 ret = this->wait(mtd, FL_ERASING);
3708 this->write_word(boundary, this->base + ONENAND_DATARAM);
3709 this->command(mtd, ONENAND_CMD_PROG, addr, 0);
3710 ret = this->wait(mtd, FL_WRITING);
3717 this->command(mtd, FLEXONENAND_CMD_PI_UPDATE, die, 0);
3718 ret = this->wait(mtd, FL_WRITING);
3720 this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_REG_COMMAND);
3721 this->wait(mtd, FL_RESETING);
3738 struct onenand_chip *this = mtd->priv;
3743 syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
3745 this->write_word((syscfg & ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE), this->base + ONENAND_REG_SYS_CFG1);
3748 this->write_word(ONENAND_CMD_READID, this->base + ONENAND_BOOTRAM);
3751 bram_maf_id = this->read_word(this->base + ONENAND_BOOTRAM + 0x0);
3752 bram_dev_id = this->read_word(this->base + ONENAND_BOOTRAM + 0x2);
3755 this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_BOOTRAM);
3757 this->wait(mtd, FL_RESETING);
3760 this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
3767 maf_id = this->read_word(this->base + ONENAND_REG_MANUFACTURER_ID);
3768 dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);
3783 struct onenand_chip *this = mtd->priv;
3788 ret = this->chip_probe(mtd);
3793 maf_id = this->read_word(this->base + ONENAND_REG_MANUFACTURER_ID);
3794 dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);
3795 ver_id = this->read_word(this->base + ONENAND_REG_VERSION_ID);
3796 this->technology = this->read_word(this->base + ONENAND_REG_TECHNOLOGY);
3800 this->device_id = dev_id;
3801 this->version_id = ver_id;
3807 if (FLEXONENAND(this)) {
3808 this->dies = ONENAND_IS_DDP(this) ? 2 : 1;
3810 mtd->numeraseregions = this->dies << 1;
3812 * (this->dies << 1), GFP_KERNEL);
3821 this->chipsize = (16 << density) << 20;
3825 mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE);
3827 if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this))
3838 if (FLEXONENAND(this))
3841 this->erase_shift = ffs(mtd->erasesize) - 1;
3842 this->page_shift = ffs(mtd->writesize) - 1;
3843 this->page_mask = (1 << (this->erase_shift - this->page_shift)) - 1;
3845 if (ONENAND_IS_DDP(this))
3846 this->density_mask = this->chipsize >> (this->erase_shift + 1);
3848 this->writesize = mtd->writesize;
3852 if (FLEXONENAND(this))
3855 mtd->size = this->chipsize;
3863 if (ONENAND_IS_2PLANE(this)) {
3886 struct onenand_chip *this = mtd->priv;
3888 if (this->state == FL_PM_SUSPENDED)
3908 struct onenand_chip *this = mtd->priv;
3910 if (!this->read_word)
3911 this->read_word = onenand_readw;
3912 if (!this->write_word)
3913 this->write_word = onenand_writew;
3915 if (!this->command)
3916 this->command = onenand_command;
3917 if (!this->wait)
3919 if (!this->bbt_wait)
3920 this->bbt_wait = onenand_bbt_wait;
3921 if (!this->unlock_all)
3922 this->unlock_all = onenand_unlock_all;
3924 if (!this->chip_probe)
3925 this->chip_probe = onenand_chip_probe;
3927 if (!this->read_bufferram)
3928 this->read_bufferram = onenand_read_bufferram;
3929 if (!this->write_bufferram)
3930 this->write_bufferram = onenand_write_bufferram;
3932 if (!this->block_markbad)
3933 this->block_markbad = onenand_default_block_markbad;
3934 if (!this->scan_bbt)
3935 this->scan_bbt = onenand_default_bbt;
3941 if (this->mmcontrol) {
3943 this->read_bufferram = onenand_sync_read_bufferram;
3947 if (!this->page_buf) {
3948 this->page_buf = kzalloc(mtd->writesize, GFP_KERNEL);
3949 if (!this->page_buf) {
3955 this->verify_buf = kzalloc(mtd->writesize, GFP_KERNEL);
3956 if (!this->verify_buf) {
3957 kfree(this->page_buf);
3961 this->options |= ONENAND_PAGEBUF_ALLOC;
3963 if (!this->oob_buf) {
3964 this->oob_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
3965 if (!this->oob_buf) {
3968 if (this->options & ONENAND_PAGEBUF_ALLOC) {
3969 this->options &= ~ONENAND_PAGEBUF_ALLOC;
3970 kfree(this->page_buf);
3974 this->options |= ONENAND_OOBBUF_ALLOC;
3977 this->state = FL_READY;
3978 init_waitqueue_head(&this->wq);
3979 spin_lock_init(&this->chip_lock);
3986 this->ecclayout = &onenand_oob_128;
3990 this->ecclayout = &onenand_oob_64;
3995 this->ecclayout = &onenand_oob_32;
4004 this->ecclayout = &onenand_oob_32;
4008 this->subpagesize = mtd->writesize >> mtd->subpage_sft;
4014 this->ecclayout->oobavail = 0;
4016 this->ecclayout->oobfree[i].length; i++)
4017 this->ecclayout->oobavail +=
4018 this->ecclayout->oobfree[i].length;
4019 mtd->oobavail = this->ecclayout->oobavail;
4021 mtd->ecclayout = this->ecclayout;
4052 this->unlock_all(mtd);
4054 ret = this->scan_bbt(mtd);
4055 if ((!FLEXONENAND(this)) || ret)
4072 struct onenand_chip *this = mtd->priv;
4082 if (this->bbm) {
4083 struct bbm_info *bbm = this->bbm;
4085 kfree(this->bbm);
4088 if (this->options & ONENAND_PAGEBUF_ALLOC) {
4089 kfree(this->page_buf);
4091 kfree(this->verify_buf);
4094 if (this->options & ONENAND_OOBBUF_ALLOC)
4095 kfree(this->oob_buf);