Lines Matching refs:this

218  * @this:		onenand chip data structure
224 static int onenand_block_address(struct onenand_chip *this, int block)
227 if (block & this->density_mask)
228 return ONENAND_DDP_CHIP1 | (block ^ this->density_mask);
235 * @this: onenand chip data structure
241 static int onenand_bufferram_address(struct onenand_chip *this, int block)
244 if (block & this->density_mask)
298 * @this: - OneNAND device structure
301 static unsigned flexonenand_block(struct onenand_chip *this, loff_t addr)
305 if (ONENAND_IS_DDP(this) && addr >= this->diesize[0]) {
307 addr -= this->diesize[0];
310 boundary = this->boundary[die];
312 blk = addr >> (this->erase_shift - 1);
316 blk += die ? this->density_mask : 0;
320 inline unsigned onenand_block(struct onenand_chip *this, loff_t addr)
322 if (!FLEXONENAND(this))
323 return addr >> this->erase_shift;
324 return flexonenand_block(this, addr);
329 * @this: OneNAND device structure
334 static loff_t flexonenand_addr(struct onenand_chip *this, int block)
339 if (ONENAND_IS_DDP(this) && block >= this->density_mask) {
340 block -= this->density_mask;
342 ofs = this->diesize[0];
345 boundary = this->boundary[die];
346 ofs += (loff_t)block << (this->erase_shift - 1);
348 ofs += (loff_t)(block - boundary - 1) << (this->erase_shift - 1);
352 loff_t onenand_addr(struct onenand_chip *this, int block)
354 if (!FLEXONENAND(this))
355 return (loff_t)block << this->erase_shift;
356 return flexonenand_addr(this, block);
400 struct onenand_chip *this = mtd->priv;
415 block = addr * this->density_mask;
424 block = onenand_block(this, addr);
430 block = addr * this->density_mask;
435 block = onenand_block(this, addr);
436 if (FLEXONENAND(this))
437 page = (int) (addr - onenand_addr(this, block))>>\
438 this->page_shift;
440 page = (int) (addr >> this->page_shift);
441 if (ONENAND_IS_2PLANE(this)) {
445 if (addr & this->writesize)
449 page &= this->page_mask;
456 value = onenand_bufferram_address(this, block);
457 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
459 if (ONENAND_IS_2PLANE(this) || ONENAND_IS_4KB_PAGE(this))
461 ONENAND_SET_BUFFERRAM0(this);
464 ONENAND_SET_NEXT_BUFFERRAM(this);
471 value = onenand_block_address(this, block);
472 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
475 value = onenand_bufferram_address(this, block);
476 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
488 if (ONENAND_IS_4KB_PAGE(this))
490 dataram = ONENAND_SET_BUFFERRAM0(this);
492 dataram = ONENAND_SET_NEXT_BUFFERRAM(this);
496 if (ONENAND_IS_2PLANE(this) && cmd == ONENAND_CMD_PROG)
498 dataram = ONENAND_CURRENT_BUFFERRAM(this);
504 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS8);
508 this->write_word(value, this->base + ONENAND_REG_START_BUFFER);
512 this->write_word(ONENAND_INT_CLEAR, this->base + ONENAND_REG_INTERRUPT);
515 this->write_word(cmd, this->base + ONENAND_REG_COMMAND);
522 * @this: onenand chip structure
524 static inline int onenand_read_ecc(struct onenand_chip *this)
528 if (!FLEXONENAND(this) && !ONENAND_IS_4KB_PAGE(this))
529 return this->read_word(this->base + ONENAND_REG_ECC_STATUS);
532 ecc = this->read_word(this->base + ONENAND_REG_ECC_STATUS + i*2);
555 struct onenand_chip * this = mtd->priv;
564 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
573 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
575 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
583 int ecc = onenand_read_ecc(this);
635 struct onenand_chip *this = data;
638 if (!this->complete.done)
639 complete(&this->complete);
653 struct onenand_chip *this = mtd->priv;
655 wait_for_completion(&this->complete);
669 struct onenand_chip *this = mtd->priv;
673 this->wait = onenand_interrupt_wait;
676 remain = wait_for_completion_timeout(&this->complete, timeout);
682 free_irq(this->irq, this);
684 this->wait = onenand_wait;
700 struct onenand_chip *this = mtd->priv;
703 init_completion(&this->complete);
705 if (this->irq <= 0) {
706 this->wait = onenand_wait;
710 if (request_irq(this->irq, &onenand_interrupt,
711 IRQF_SHARED, "onenand", this)) {
713 this->wait = onenand_wait;
718 syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
720 this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
722 this->wait = onenand_try_interrupt_wait;
735 struct onenand_chip *this = mtd->priv;
737 if (ONENAND_CURRENT_BUFFERRAM(this)) {
738 /* Note: the 'this->writesize' is a real page size */
740 return this->writesize;
761 struct onenand_chip *this = mtd->priv;
764 bufferram = this->base + area;
775 word = this->read_word(bufferram + offset + count);
797 struct onenand_chip *this = mtd->priv;
800 bufferram = this->base + area;
804 this->mmcontrol(mtd, ONENAND_SYS_CFG1_SYNC_READ);
813 word = this->read_word(bufferram + offset + count);
819 this->mmcontrol(mtd, 0);
837 struct onenand_chip *this = mtd->priv;
840 bufferram = this->base + area;
855 word = this->read_word(bufferram + byte_offset);
857 this->write_word(word, bufferram + byte_offset);
875 struct onenand_chip *this = mtd->priv;
879 block = (int) (addr >> this->erase_shift) & ~1;
881 if (addr & this->writesize)
883 page = (int) (addr >> (this->page_shift + 1)) & this->page_mask;
899 struct onenand_chip *this = mtd->priv;
903 if (ONENAND_IS_2PLANE(this))
906 blockpage = (int) (addr >> this->page_shift);
909 i = ONENAND_CURRENT_BUFFERRAM(this);
910 if (this->bufferram[i].blockpage == blockpage)
914 i = ONENAND_NEXT_BUFFERRAM(this);
915 if (this->bufferram[i].blockpage == blockpage) {
916 ONENAND_SET_NEXT_BUFFERRAM(this);
921 if (found && ONENAND_IS_DDP(this)) {
923 int block = onenand_block(this, addr);
924 int value = onenand_bufferram_address(this, block);
925 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
942 struct onenand_chip *this = mtd->priv;
946 if (ONENAND_IS_2PLANE(this))
949 blockpage = (int) (addr >> this->page_shift);
952 i = ONENAND_NEXT_BUFFERRAM(this);
953 if (this->bufferram[i].blockpage == blockpage)
954 this->bufferram[i].blockpage = -1;
957 i = ONENAND_CURRENT_BUFFERRAM(this);
959 this->bufferram[i].blockpage = blockpage;
961 this->bufferram[i].blockpage = -1;
975 struct onenand_chip *this = mtd->priv;
981 loff_t buf_addr = this->bufferram[i].blockpage << this->page_shift;
983 this->bufferram[i].blockpage = -1;
996 struct onenand_chip *this = mtd->priv;
1003 spin_lock(&this->chip_lock);
1004 if (this->state == FL_READY) {
1005 this->state = new_state;
1006 spin_unlock(&this->chip_lock);
1007 if (new_state != FL_PM_SUSPENDED && this->enable)
1008 this->enable(mtd);
1012 spin_unlock(&this->chip_lock);
1013 return (this->state == FL_PM_SUSPENDED) ? 0 : -EAGAIN;
1016 add_wait_queue(&this->wq, &wait);
1017 spin_unlock(&this->chip_lock);
1019 remove_wait_queue(&this->wq, &wait);
1033 struct onenand_chip *this = mtd->priv;
1035 if (this->state != FL_PM_SUSPENDED && this->disable)
1036 this->disable(mtd);
1038 spin_lock(&this->chip_lock);
1039 this->state = FL_READY;
1040 wake_up(&this->wq);
1041 spin_unlock(&this->chip_lock);
1054 struct onenand_chip *this = mtd->priv;
1056 this->read_bufferram(mtd, ONENAND_SPARERAM, this->oob_buf, 0,
1058 return mtd_ooblayout_get_databytes(mtd, buf, this->oob_buf,
1077 struct onenand_chip *this = mtd->priv;
1081 if (!FLEXONENAND(this))
1090 if (mtd->eraseregions[i].erasesize < (1 << this->erase_shift))
1101 this->command(mtd, FLEXONENAND_CMD_RECOVER_LSB, addr, this->writesize);
1102 return this->wait(mtd, FL_READING);
1117 struct onenand_chip *this = mtd->priv;
1126 int writesize = this->writesize;
1155 this->command(mtd, ONENAND_CMD_READ, from, writesize);
1157 ret = this->wait(mtd, FL_READING);
1167 this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);
1175 this->read_bufferram(mtd, ONENAND_SPARERAM, oobbuf, oobcolumn, thisooblen);
1218 struct onenand_chip *this = mtd->priv;
1227 int writesize = this->writesize;
1251 this->command(mtd, ONENAND_CMD_READ, from, writesize);
1252 ret = this->wait(mtd, FL_READING);
1268 this->command(mtd, ONENAND_CMD_READ, from, writesize);
1274 if (ONENAND_IS_DDP(this) &&
1275 unlikely(from == (this->chipsize >> 1))) {
1276 this->write_word(ONENAND_DDP_CHIP0, this->base + ONENAND_REG_START_ADDRESS2);
1280 ONENAND_SET_PREV_BUFFERRAM(this);
1283 this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen);
1293 this->read_bufferram(mtd, ONENAND_SPARERAM, oobbuf, oobcolumn, thisooblen);
1305 this->write_word(ONENAND_DDP_CHIP1, this->base + ONENAND_REG_START_ADDRESS2);
1306 ONENAND_SET_NEXT_BUFFERRAM(this);
1312 ret = this->wait(mtd, FL_READING);
1347 struct onenand_chip *this = mtd->priv;
1378 readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1386 this->command(mtd, readcmd, from, mtd->oobsize);
1390 ret = this->wait(mtd, FL_READING);
1403 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen);
1442 struct onenand_chip *this = mtd->priv;
1461 ret = ONENAND_IS_4KB_PAGE(this) ?
1488 struct onenand_chip *this = mtd->priv;
1495 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
1500 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
1501 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
1502 addr1 = this->read_word(this->base + ONENAND_REG_START_ADDRESS1);
1503 addr8 = this->read_word(this->base + ONENAND_REG_START_ADDRESS8);
1506 ecc = onenand_read_ecc(this);
1541 struct onenand_chip *this = mtd->priv;
1565 readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1573 this->command(mtd, readcmd, from, mtd->oobsize);
1577 ret = this->bbt_wait(mtd, FL_READING);
1584 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen);
1594 from += this->writesize;
1615 struct onenand_chip *this = mtd->priv;
1616 u_char *oob_buf = this->oob_buf;
1619 readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1621 this->command(mtd, readcmd, to, mtd->oobsize);
1623 status = this->wait(mtd, FL_READING);
1627 this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize);
1644 struct onenand_chip *this = mtd->priv;
1648 column = addr & (this->writesize - 1);
1651 thislen = min_t(int, this->writesize - column, len);
1653 this->command(mtd, ONENAND_CMD_READ, addr, this->writesize);
1657 ret = this->wait(mtd, FL_READING);
1663 this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize);
1665 if (memcmp(buf, this->verify_buf + column, thislen))
1681 #define NOTALIGNED(x) ((x & (this->subpagesize - 1)) != 0)
1685 struct onenand_chip *this = mtd->priv;
1690 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
1710 struct onenand_chip *this = mtd->priv;
1714 if (this->state == FL_PM_SUSPENDED)
1737 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen);
1742 memset(this->page_buf, 0xff, mtd->writesize);
1743 memcpy(this->page_buf + column, buf, thislen);
1744 wbuf = this->page_buf;
1747 this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize);
1748 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
1750 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
1756 if (ONENAND_IS_2PLANE(this)) {
1757 ONENAND_SET_BUFFERRAM1(this);
1758 onenand_update_bufferram(mtd, to + this->writesize, !subpage);
1800 struct onenand_chip *this = mtd->priv;
1843 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen);
1848 memset(this->page_buf, 0xff, mtd->writesize);
1849 memcpy(this->page_buf + column, buf, thislen);
1850 wbuf = this->page_buf;
1853 this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize);
1856 oobbuf = this->oob_buf;
1872 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize);
1874 ONENAND_SET_NEXT_BUFFERRAM(this);
1880 if (!ONENAND_IS_2PLANE(this) && !ONENAND_IS_4KB_PAGE(this) && !first) {
1881 ONENAND_SET_PREV_BUFFERRAM(this);
1883 ret = this->wait(mtd, FL_WRITING);
1903 ONENAND_SET_NEXT_BUFFERRAM(this);
1906 this->ongoing = 0;
1910 if (ONENAND_IS_CACHE_PROGRAM(this) &&
1911 likely(onenand_block(this, to) != 0) &&
1912 ONENAND_IS_4KB_PAGE(this) &&
1915 this->ongoing = 1;
1918 this->command(mtd, cmd, to, mtd->writesize);
1923 if (ONENAND_IS_2PLANE(this) || ONENAND_IS_4KB_PAGE(this)) {
1924 ret = this->wait(mtd, FL_WRITING);
1981 struct onenand_chip *this = mtd->priv;
2017 oobbuf = this->oob_buf;
2019 oobcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_PROG : ONENAND_CMD_PROGOOB;
2027 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobsize);
2036 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize);
2038 if (ONENAND_IS_4KB_PAGE(this)) {
2040 memset(this->page_buf, 0xff, mtd->writesize);
2041 this->write_bufferram(mtd, ONENAND_DATARAM,
2042 this->page_buf, 0, mtd->writesize);
2045 this->command(mtd, oobcmd, to, mtd->oobsize);
2048 if (ONENAND_IS_2PLANE(this)) {
2049 ONENAND_SET_BUFFERRAM1(this);
2050 onenand_update_bufferram(mtd, to + this->writesize, 0);
2053 ret = this->wait(mtd, FL_WRITING);
2122 struct onenand_chip *this = mtd->priv;
2123 struct bbm_info *bbm = this->bbm;
2133 struct onenand_chip *this = mtd->priv;
2136 unsigned int block_size = (1 << this->erase_shift);
2140 this->command(mtd, ONENAND_CMD_ERASE_VERIFY, addr, block_size);
2141 ret = this->wait(mtd, FL_VERIFYING_ERASE);
2144 __func__, onenand_block(this, addr));
2166 struct onenand_chip *this = mtd->priv;
2173 if (ONENAND_IS_DDP(this)) {
2174 loff_t bdry_addr = this->chipsize >> 1;
2176 bdry_block = bdry_addr >> this->erase_shift;
2205 int this_block = (addr >> this->erase_shift);
2216 this->command(mtd, ONENAND_CMD_MULTIBLOCK_ERASE,
2220 ret = this->wait(mtd, FL_PREPARING_ERASE);
2224 onenand_block(this, addr));
2236 this->command(mtd, ONENAND_CMD_ERASE, addr, block_size);
2239 ret = this->wait(mtd, FL_ERASING);
2243 __func__, onenand_block(this, addr));
2278 struct onenand_chip *this = mtd->priv;
2301 this->command(mtd, ONENAND_CMD_ERASE, addr, block_size);
2305 ret = this->wait(mtd, FL_ERASING);
2309 __func__, onenand_block(this, addr));
2345 struct onenand_chip *this = mtd->priv;
2357 if (FLEXONENAND(this)) {
2358 /* Find the eraseregion of this address */
2369 block_size = 1 << this->erase_shift;
2386 if (ONENAND_IS_4KB_PAGE(this) || region ||
2445 struct onenand_chip *this = mtd->priv;
2446 struct bbm_info *bbm = this->bbm;
2457 block = onenand_block(this, ofs);
2462 ofs += mtd->oobsize + (this->badblockpos & ~0x01);
2479 struct onenand_chip *this = mtd->priv;
2491 ret = this->block_markbad(mtd, ofs);
2507 struct onenand_chip *this = mtd->priv;
2511 start = onenand_block(this, ofs);
2512 end = onenand_block(this, ofs + len) - 1;
2520 if (this->options & ONENAND_HAS_CONT_LOCK) {
2522 this->write_word(start, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2524 this->write_word(end, this->base + ONENAND_REG_END_BLOCK_ADDRESS);
2526 this->command(mtd, cmd, 0, 0);
2529 this->wait(mtd, FL_LOCKING);
2532 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
2537 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
2548 value = onenand_block_address(this, block);
2549 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
2551 value = onenand_bufferram_address(this, block);
2552 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
2554 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2556 this->command(mtd, cmd, 0, 0);
2559 this->wait(mtd, FL_LOCKING);
2562 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
2567 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
2614 * @this: onenand chip data structure
2618 static int onenand_check_lock_status(struct onenand_chip *this)
2623 end = this->chipsize >> this->erase_shift;
2626 value = onenand_block_address(this, block);
2627 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
2629 value = onenand_bufferram_address(this, block);
2630 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
2632 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2635 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
2654 struct onenand_chip *this = mtd->priv;
2658 if (this->options & ONENAND_HAS_UNLOCK_ALL) {
2660 this->write_word(0, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2662 this->command(mtd, ONENAND_CMD_UNLOCK_ALL, 0, 0);
2665 this->wait(mtd, FL_LOCKING);
2668 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
2673 if (this->options & ONENAND_SKIP_UNLOCK_CHECK)
2677 if (onenand_check_lock_status(this))
2681 if (ONENAND_IS_DDP(this) && !FLEXONENAND(this)) {
2683 ofs = this->chipsize >> 1;
2684 len = this->chipsize >> 1;
2703 struct onenand_chip *this = mtd->priv;
2709 block = (int) (addr >> this->erase_shift);
2714 block = (int) (addr >> this->erase_shift);
2715 page = (int) (addr >> this->page_shift);
2717 if (ONENAND_IS_2PLANE(this)) {
2721 if (addr & this->writesize)
2725 page &= this->page_mask;
2731 value = onenand_block_address(this, block);
2732 this->write_word(value, this->base +
2743 if (ONENAND_IS_2PLANE(this) && cmd == ONENAND_CMD_PROG)
2745 dataram = ONENAND_CURRENT_BUFFERRAM(this);
2751 this->write_word(value, this->base +
2756 this->write_word(value, this->base + ONENAND_REG_START_BUFFER);
2760 this->write_word(ONENAND_INT_CLEAR, this->base + ONENAND_REG_INTERRUPT);
2763 this->write_word(cmd, this->base + ONENAND_REG_COMMAND);
2779 struct onenand_chip *this = mtd->priv;
2796 oobbuf = this->oob_buf;
2804 block = (int) (to >> this->erase_shift);
2810 value = onenand_block_address(this, block);
2811 this->write_word(value, this->base +
2819 value = onenand_bufferram_address(this, block);
2820 this->write_word(value, this->base +
2822 ONENAND_SET_NEXT_BUFFERRAM(this);
2827 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
2828 this->wait(mtd, FL_OTPING);
2840 this->write_bufferram(mtd, ONENAND_SPARERAM,
2845 if (ONENAND_IS_2PLANE(this)) {
2846 ONENAND_SET_BUFFERRAM1(this);
2847 onenand_update_bufferram(mtd, to + this->writesize, 0);
2850 ret = this->wait(mtd, FL_WRITING);
2857 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2858 this->wait(mtd, FL_RESETTING);
2860 status = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
2910 struct onenand_chip *this = mtd->priv;
2920 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
2921 this->wait(mtd, FL_OTPING);
2923 ret = ONENAND_IS_4KB_PAGE(this) ?
2928 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2929 this->wait(mtd, FL_RESETTING);
2947 struct onenand_chip *this = mtd->priv;
2954 memcpy(this->page_buf, buf, len);
2955 memset(this->page_buf + len, 0xff, mtd->writesize - len);
2956 pbuf = this->page_buf;
2961 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
2962 this->wait(mtd, FL_OTPING);
2972 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2973 this->wait(mtd, FL_RESETTING);
2991 struct onenand_chip *this = mtd->priv;
2995 if (FLEXONENAND(this)) {
2998 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
2999 this->wait(mtd, FL_OTPING);
3012 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3013 this->wait(mtd, FL_RESETTING);
3042 struct onenand_chip *this = mtd->priv;
3049 density = onenand_get_density(this->device_id);
3199 struct onenand_chip *this = mtd->priv;
3200 u_char *buf = FLEXONENAND(this) ? this->page_buf : this->oob_buf;
3205 memset(buf, 0xff, FLEXONENAND(this) ? this->writesize
3215 len = FLEXONENAND(this) ? mtd->writesize : 16;
3223 if (FLEXONENAND(this))
3253 struct onenand_chip *this = mtd->priv;
3257 density = onenand_get_density(this->device_id);
3258 process = this->version_id >> ONENAND_VERSION_PROCESS_SHIFT;
3259 numbufs = this->read_word(this->base + ONENAND_REG_NUM_BUFFERS) >> 8;
3264 this->options |= ONENAND_HAS_NOP_1;
3267 if (ONENAND_IS_DDP(this))
3268 this->options |= ONENAND_HAS_2PLANE;
3270 this->options |= ONENAND_HAS_4KB_PAGE;
3271 this->options |= ONENAND_HAS_CACHE_PROGRAM;
3283 if ((this->version_id & 0xf) == 0xe)
3284 this->options |= ONENAND_HAS_NOP_1;
3286 this->options |= ONENAND_HAS_UNLOCK_ALL;
3291 if (!ONENAND_IS_DDP(this))
3292 this->options |= ONENAND_HAS_2PLANE;
3293 this->options |= ONENAND_HAS_UNLOCK_ALL;
3299 this->options |= ONENAND_HAS_UNLOCK_ALL;
3305 this->options |= ONENAND_HAS_CONT_LOCK;
3310 if (ONENAND_IS_MLC(this))
3311 this->options |= ONENAND_HAS_4KB_PAGE;
3313 if (ONENAND_IS_4KB_PAGE(this))
3314 this->options &= ~ONENAND_HAS_2PLANE;
3316 if (FLEXONENAND(this)) {
3317 this->options &= ~ONENAND_HAS_CONT_LOCK;
3318 this->options |= ONENAND_HAS_UNLOCK_ALL;
3321 if (this->options & ONENAND_HAS_CONT_LOCK)
3323 if (this->options & ONENAND_HAS_UNLOCK_ALL)
3325 if (this->options & ONENAND_HAS_2PLANE)
3327 if (this->options & ONENAND_HAS_4KB_PAGE)
3329 if (this->options & ONENAND_HAS_CACHE_PROGRAM)
3396 struct onenand_chip *this = mtd->priv;
3401 syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
3402 this->write_word((syscfg | 0x0100), this->base + ONENAND_REG_SYS_CFG1);
3404 for (die = 0; die < this->dies; die++) {
3405 this->command(mtd, FLEXONENAND_CMD_PI_ACCESS, die, 0);
3406 this->wait(mtd, FL_SYNCING);
3408 this->command(mtd, FLEXONENAND_CMD_READ_PI, die, 0);
3409 this->wait(mtd, FL_READING);
3411 bdry = this->read_word(this->base + ONENAND_DATARAM);
3416 this->boundary[die] = bdry & FLEXONENAND_PI_MASK;
3418 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3419 this->wait(mtd, FL_RESETTING);
3422 this->boundary[die], locked ? "(Locked)" : "(Unlocked)");
3426 this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
3437 struct onenand_chip *this = mtd->priv;
3442 density = onenand_get_density(this->device_id);
3443 blksperdie = ((loff_t)(16 << density) << 20) >> (this->erase_shift);
3444 blksperdie >>= ONENAND_IS_DDP(this) ? 1 : 0;
3446 eraseshift = this->erase_shift - 1;
3448 mtd->numeraseregions = this->dies << 1;
3454 for (; die < this->dies; die++) {
3455 if (!die || this->boundary[die-1] != maxbdry) {
3460 this->boundary[die] + 1;
3466 this->boundary[die] + 1;
3467 ofs += (this->boundary[die] + 1) << (eraseshift - 1);
3469 if (this->boundary[die] != maxbdry) {
3474 this->boundary[die];
3482 mtd->erasesize = 1 << this->erase_shift;
3494 for (die = 0, mtd->size = 0; die < this->dies; die++) {
3495 this->diesize[die] = (loff_t)blksperdie << this->erase_shift;
3496 this->diesize[die] -= (loff_t)(this->boundary[die] + 1)
3497 << (this->erase_shift - 1);
3498 mtd->size += this->diesize[die];
3513 * Avoid this by ensuring that the block to be converted is
3518 struct onenand_chip *this = mtd->priv;
3526 .oobbuf = this->oob_buf,
3533 addr = flexonenand_addr(this, block);
3546 if (this->oob_buf[i] != 0xff)
3565 struct onenand_chip *this = mtd->priv;
3570 if (die && (!ONENAND_IS_DDP(this)))
3574 if (boundary < 0 || boundary == this->boundary[die])
3577 density = onenand_get_density(this->device_id);
3578 blksperdie = ((16 << density) << 20) >> this->erase_shift;
3579 blksperdie >>= ONENAND_IS_DDP(this) ? 1 : 0;
3588 old = this->boundary[die] + (die * this->density_mask);
3589 new = boundary + (die * this->density_mask);
3597 this->command(mtd, FLEXONENAND_CMD_PI_ACCESS, die, 0);
3598 this->wait(mtd, FL_SYNCING);
3601 this->command(mtd, FLEXONENAND_CMD_READ_PI, die, 0);
3602 this->wait(mtd, FL_READING);
3604 thisboundary = this->read_word(this->base + ONENAND_DATARAM);
3614 addr = die ? this->diesize[0] : 0;
3619 this->command(mtd, ONENAND_CMD_ERASE, addr, 0);
3620 ret = this->wait(mtd, FL_ERASING);
3627 this->write_word(boundary, this->base + ONENAND_DATARAM);
3628 this->command(mtd, ONENAND_CMD_PROG, addr, 0);
3629 ret = this->wait(mtd, FL_WRITING);
3636 this->command(mtd, FLEXONENAND_CMD_PI_UPDATE, die, 0);
3637 ret = this->wait(mtd, FL_WRITING);
3639 this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_REG_COMMAND);
3640 this->wait(mtd, FL_RESETTING);
3657 struct onenand_chip *this = mtd->priv;
3662 syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
3664 this->write_word((syscfg & ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE), this->base + ONENAND_REG_SYS_CFG1);
3667 this->write_word(ONENAND_CMD_READID, this->base + ONENAND_BOOTRAM);
3670 bram_maf_id = this->read_word(this->base + ONENAND_BOOTRAM + 0x0);
3671 bram_dev_id = this->read_word(this->base + ONENAND_BOOTRAM + 0x2);
3674 this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_BOOTRAM);
3676 this->wait(mtd, FL_RESETTING);
3679 this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
3686 maf_id = this->read_word(this->base + ONENAND_REG_MANUFACTURER_ID);
3687 dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);
3702 struct onenand_chip *this = mtd->priv;
3707 ret = this->chip_probe(mtd);
3712 dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);
3713 ver_id = this->read_word(this->base + ONENAND_REG_VERSION_ID);
3714 this->technology = this->read_word(this->base + ONENAND_REG_TECHNOLOGY);
3718 this->device_id = dev_id;
3719 this->version_id = ver_id;
3725 if (FLEXONENAND(this)) {
3726 this->dies = ONENAND_IS_DDP(this) ? 2 : 1;
3728 mtd->numeraseregions = this->dies << 1;
3730 kcalloc(this->dies << 1,
3741 this->chipsize = (16 << density) << 20;
3745 mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE);
3747 if (ONENAND_IS_4KB_PAGE(this))
3758 if (FLEXONENAND(this))
3761 this->erase_shift = ffs(mtd->erasesize) - 1;
3762 this->page_shift = ffs(mtd->writesize) - 1;
3763 this->page_mask = (1 << (this->erase_shift - this->page_shift)) - 1;
3765 if (ONENAND_IS_DDP(this))
3766 this->density_mask = this->chipsize >> (this->erase_shift + 1);
3768 this->writesize = mtd->writesize;
3772 if (FLEXONENAND(this))
3775 mtd->size = this->chipsize;
3783 if (ONENAND_IS_2PLANE(this)) {
3806 struct onenand_chip *this = mtd->priv;
3808 if (this->state == FL_PM_SUSPENDED)
3828 struct onenand_chip *this = mtd->priv;
3830 if (!this->read_word)
3831 this->read_word = onenand_readw;
3832 if (!this->write_word)
3833 this->write_word = onenand_writew;
3835 if (!this->command)
3836 this->command = onenand_command;
3837 if (!this->wait)
3839 if (!this->bbt_wait)
3840 this->bbt_wait = onenand_bbt_wait;
3841 if (!this->unlock_all)
3842 this->unlock_all = onenand_unlock_all;
3844 if (!this->chip_probe)
3845 this->chip_probe = onenand_chip_probe;
3847 if (!this->read_bufferram)
3848 this->read_bufferram = onenand_read_bufferram;
3849 if (!this->write_bufferram)
3850 this->write_bufferram = onenand_write_bufferram;
3852 if (!this->block_markbad)
3853 this->block_markbad = onenand_default_block_markbad;
3854 if (!this->scan_bbt)
3855 this->scan_bbt = onenand_default_bbt;
3861 if (this->mmcontrol) {
3863 this->read_bufferram = onenand_sync_read_bufferram;
3867 if (!this->page_buf) {
3868 this->page_buf = kzalloc(mtd->writesize, GFP_KERNEL);
3869 if (!this->page_buf)
3872 this->verify_buf = kzalloc(mtd->writesize, GFP_KERNEL);
3873 if (!this->verify_buf) {
3874 kfree(this->page_buf);
3878 this->options |= ONENAND_PAGEBUF_ALLOC;
3880 if (!this->oob_buf) {
3881 this->oob_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
3882 if (!this->oob_buf) {
3883 if (this->options & ONENAND_PAGEBUF_ALLOC) {
3884 this->options &= ~ONENAND_PAGEBUF_ALLOC;
3886 kfree(this->verify_buf);
3888 kfree(this->page_buf);
3892 this->options |= ONENAND_OOBBUF_ALLOC;
3895 this->state = FL_READY;
3896 init_waitqueue_head(&this->wq);
3897 spin_lock_init(&this->chip_lock);
3904 if (FLEXONENAND(this)) {
3911 if (ONENAND_IS_NOP_1(this))
3933 this->subpagesize = mtd->writesize >> mtd->subpage_sft;
3948 mtd->type = ONENAND_IS_MLC(this) ? MTD_MLCNANDFLASH : MTD_NANDFLASH;
3975 if (!(this->options & ONENAND_SKIP_INITIAL_UNLOCKING))
3976 this->unlock_all(mtd);
3979 this->badblockpos = ONENAND_BADBLOCK_POS;
3981 ret = this->scan_bbt(mtd);
3982 if ((!FLEXONENAND(this)) || ret)
3999 struct onenand_chip *this = mtd->priv;
4005 if (this->bbm) {
4006 struct bbm_info *bbm = this->bbm;
4008 kfree(this->bbm);
4011 if (this->options & ONENAND_PAGEBUF_ALLOC) {
4012 kfree(this->page_buf);
4014 kfree(this->verify_buf);
4017 if (this->options & ONENAND_OOBBUF_ALLOC)
4018 kfree(this->oob_buf);