Lines Matching refs:this
218 * @param 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 * @param this onenand chip data structure
241 static int onenand_bufferram_address(struct onenand_chip *this, int block)
244 if (block & this->density_mask)
298 * @param 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 * @param 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;
1457 ret = ONENAND_IS_4KB_PAGE(this) ?
1476 struct onenand_chip *this = mtd->priv;
1483 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
1488 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
1489 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
1490 addr1 = this->read_word(this->base + ONENAND_REG_START_ADDRESS1);
1491 addr8 = this->read_word(this->base + ONENAND_REG_START_ADDRESS8);
1494 ecc = onenand_read_ecc(this);
1529 struct onenand_chip *this = mtd->priv;
1553 readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1561 this->command(mtd, readcmd, from, mtd->oobsize);
1565 ret = this->bbt_wait(mtd, FL_READING);
1572 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen);
1582 from += this->writesize;
1603 struct onenand_chip *this = mtd->priv;
1604 u_char *oob_buf = this->oob_buf;
1607 readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1609 this->command(mtd, readcmd, to, mtd->oobsize);
1611 status = this->wait(mtd, FL_READING);
1615 this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize);
1632 struct onenand_chip *this = mtd->priv;
1636 column = addr & (this->writesize - 1);
1639 thislen = min_t(int, this->writesize - column, len);
1641 this->command(mtd, ONENAND_CMD_READ, addr, this->writesize);
1645 ret = this->wait(mtd, FL_READING);
1651 this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize);
1653 if (memcmp(buf, this->verify_buf + column, thislen))
1669 #define NOTALIGNED(x) ((x & (this->subpagesize - 1)) != 0)
1673 struct onenand_chip *this = mtd->priv;
1678 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT);
1698 struct onenand_chip *this = mtd->priv;
1702 if (this->state == FL_PM_SUSPENDED)
1725 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen);
1730 memset(this->page_buf, 0xff, mtd->writesize);
1731 memcpy(this->page_buf + column, buf, thislen);
1732 wbuf = this->page_buf;
1735 this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize);
1736 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
1738 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
1744 if (ONENAND_IS_2PLANE(this)) {
1745 ONENAND_SET_BUFFERRAM1(this);
1746 onenand_update_bufferram(mtd, to + this->writesize, !subpage);
1788 struct onenand_chip *this = mtd->priv;
1831 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen);
1836 memset(this->page_buf, 0xff, mtd->writesize);
1837 memcpy(this->page_buf + column, buf, thislen);
1838 wbuf = this->page_buf;
1841 this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize);
1844 oobbuf = this->oob_buf;
1860 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize);
1862 ONENAND_SET_NEXT_BUFFERRAM(this);
1868 if (!ONENAND_IS_2PLANE(this) && !ONENAND_IS_4KB_PAGE(this) && !first) {
1869 ONENAND_SET_PREV_BUFFERRAM(this);
1871 ret = this->wait(mtd, FL_WRITING);
1891 ONENAND_SET_NEXT_BUFFERRAM(this);
1894 this->ongoing = 0;
1898 if (ONENAND_IS_CACHE_PROGRAM(this) &&
1899 likely(onenand_block(this, to) != 0) &&
1900 ONENAND_IS_4KB_PAGE(this) &&
1903 this->ongoing = 1;
1906 this->command(mtd, cmd, to, mtd->writesize);
1911 if (ONENAND_IS_2PLANE(this) || ONENAND_IS_4KB_PAGE(this)) {
1912 ret = this->wait(mtd, FL_WRITING);
1972 struct onenand_chip *this = mtd->priv;
2008 oobbuf = this->oob_buf;
2010 oobcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_PROG : ONENAND_CMD_PROGOOB;
2018 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobsize);
2027 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize);
2029 if (ONENAND_IS_4KB_PAGE(this)) {
2031 memset(this->page_buf, 0xff, mtd->writesize);
2032 this->write_bufferram(mtd, ONENAND_DATARAM,
2033 this->page_buf, 0, mtd->writesize);
2036 this->command(mtd, oobcmd, to, mtd->oobsize);
2039 if (ONENAND_IS_2PLANE(this)) {
2040 ONENAND_SET_BUFFERRAM1(this);
2041 onenand_update_bufferram(mtd, to + this->writesize, 0);
2044 ret = this->wait(mtd, FL_WRITING);
2113 struct onenand_chip *this = mtd->priv;
2114 struct bbm_info *bbm = this->bbm;
2124 struct onenand_chip *this = mtd->priv;
2127 unsigned int block_size = (1 << this->erase_shift);
2131 this->command(mtd, ONENAND_CMD_ERASE_VERIFY, addr, block_size);
2132 ret = this->wait(mtd, FL_VERIFYING_ERASE);
2135 __func__, onenand_block(this, addr));
2157 struct onenand_chip *this = mtd->priv;
2164 if (ONENAND_IS_DDP(this)) {
2165 loff_t bdry_addr = this->chipsize >> 1;
2167 bdry_block = bdry_addr >> this->erase_shift;
2196 int this_block = (addr >> this->erase_shift);
2207 this->command(mtd, ONENAND_CMD_MULTIBLOCK_ERASE,
2211 ret = this->wait(mtd, FL_PREPARING_ERASE);
2215 onenand_block(this, addr));
2227 this->command(mtd, ONENAND_CMD_ERASE, addr, block_size);
2230 ret = this->wait(mtd, FL_ERASING);
2234 __func__, onenand_block(this, addr));
2269 struct onenand_chip *this = mtd->priv;
2292 this->command(mtd, ONENAND_CMD_ERASE, addr, block_size);
2296 ret = this->wait(mtd, FL_ERASING);
2300 __func__, onenand_block(this, addr));
2336 struct onenand_chip *this = mtd->priv;
2348 if (FLEXONENAND(this)) {
2349 /* Find the eraseregion of this address */
2360 block_size = 1 << this->erase_shift;
2377 if (ONENAND_IS_4KB_PAGE(this) || region ||
2436 struct onenand_chip *this = mtd->priv;
2437 struct bbm_info *bbm = this->bbm;
2448 block = onenand_block(this, ofs);
2453 ofs += mtd->oobsize + (this->badblockpos & ~0x01);
2470 struct onenand_chip *this = mtd->priv;
2482 ret = this->block_markbad(mtd, ofs);
2498 struct onenand_chip *this = mtd->priv;
2502 start = onenand_block(this, ofs);
2503 end = onenand_block(this, ofs + len) - 1;
2511 if (this->options & ONENAND_HAS_CONT_LOCK) {
2513 this->write_word(start, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2515 this->write_word(end, this->base + ONENAND_REG_END_BLOCK_ADDRESS);
2517 this->command(mtd, cmd, 0, 0);
2520 this->wait(mtd, FL_LOCKING);
2523 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
2528 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
2539 value = onenand_block_address(this, block);
2540 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
2542 value = onenand_bufferram_address(this, block);
2543 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
2545 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2547 this->command(mtd, cmd, 0, 0);
2550 this->wait(mtd, FL_LOCKING);
2553 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
2558 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
2605 * @param this onenand chip data structure
2609 static int onenand_check_lock_status(struct onenand_chip *this)
2614 end = this->chipsize >> this->erase_shift;
2617 value = onenand_block_address(this, block);
2618 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
2620 value = onenand_bufferram_address(this, block);
2621 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
2623 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2626 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
2645 struct onenand_chip *this = mtd->priv;
2649 if (this->options & ONENAND_HAS_UNLOCK_ALL) {
2651 this->write_word(0, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
2653 this->command(mtd, ONENAND_CMD_UNLOCK_ALL, 0, 0);
2656 this->wait(mtd, FL_LOCKING);
2659 while (this->read_word(this->base + ONENAND_REG_CTRL_STATUS)
2664 if (this->options & ONENAND_SKIP_UNLOCK_CHECK)
2668 if (onenand_check_lock_status(this))
2672 if (ONENAND_IS_DDP(this) && !FLEXONENAND(this)) {
2674 ofs = this->chipsize >> 1;
2675 len = this->chipsize >> 1;
2694 struct onenand_chip *this = mtd->priv;
2700 block = (int) (addr >> this->erase_shift);
2705 block = (int) (addr >> this->erase_shift);
2706 page = (int) (addr >> this->page_shift);
2708 if (ONENAND_IS_2PLANE(this)) {
2712 if (addr & this->writesize)
2716 page &= this->page_mask;
2722 value = onenand_block_address(this, block);
2723 this->write_word(value, this->base +
2734 if (ONENAND_IS_2PLANE(this) && cmd == ONENAND_CMD_PROG)
2736 dataram = ONENAND_CURRENT_BUFFERRAM(this);
2742 this->write_word(value, this->base +
2747 this->write_word(value, this->base + ONENAND_REG_START_BUFFER);
2751 this->write_word(ONENAND_INT_CLEAR, this->base + ONENAND_REG_INTERRUPT);
2754 this->write_word(cmd, this->base + ONENAND_REG_COMMAND);
2772 struct onenand_chip *this = mtd->priv;
2789 oobbuf = this->oob_buf;
2797 block = (int) (to >> this->erase_shift);
2803 value = onenand_block_address(this, block);
2804 this->write_word(value, this->base +
2812 value = onenand_bufferram_address(this, block);
2813 this->write_word(value, this->base +
2815 ONENAND_SET_NEXT_BUFFERRAM(this);
2820 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
2821 this->wait(mtd, FL_OTPING);
2833 this->write_bufferram(mtd, ONENAND_SPARERAM,
2838 if (ONENAND_IS_2PLANE(this)) {
2839 ONENAND_SET_BUFFERRAM1(this);
2840 onenand_update_bufferram(mtd, to + this->writesize, 0);
2843 ret = this->wait(mtd, FL_WRITING);
2850 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2851 this->wait(mtd, FL_RESETTING);
2853 status = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
2903 struct onenand_chip *this = mtd->priv;
2913 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
2914 this->wait(mtd, FL_OTPING);
2916 ret = ONENAND_IS_4KB_PAGE(this) ?
2921 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2922 this->wait(mtd, FL_RESETTING);
2940 struct onenand_chip *this = mtd->priv;
2947 memcpy(this->page_buf, buf, len);
2948 memset(this->page_buf + len, 0xff, mtd->writesize - len);
2949 pbuf = this->page_buf;
2954 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
2955 this->wait(mtd, FL_OTPING);
2965 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2966 this->wait(mtd, FL_RESETTING);
2984 struct onenand_chip *this = mtd->priv;
2988 if (FLEXONENAND(this)) {
2991 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
2992 this->wait(mtd, FL_OTPING);
3005 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3006 this->wait(mtd, FL_RESETTING);
3035 struct onenand_chip *this = mtd->priv;
3042 density = onenand_get_density(this->device_id);
3191 struct onenand_chip *this = mtd->priv;
3192 u_char *buf = FLEXONENAND(this) ? this->page_buf : this->oob_buf;
3197 memset(buf, 0xff, FLEXONENAND(this) ? this->writesize
3207 len = FLEXONENAND(this) ? mtd->writesize : 16;
3215 if (FLEXONENAND(this))
3245 struct onenand_chip *this = mtd->priv;
3249 density = onenand_get_density(this->device_id);
3250 process = this->version_id >> ONENAND_VERSION_PROCESS_SHIFT;
3251 numbufs = this->read_word(this->base + ONENAND_REG_NUM_BUFFERS) >> 8;
3256 this->options |= ONENAND_HAS_NOP_1;
3259 if (ONENAND_IS_DDP(this))
3260 this->options |= ONENAND_HAS_2PLANE;
3262 this->options |= ONENAND_HAS_4KB_PAGE;
3263 this->options |= ONENAND_HAS_CACHE_PROGRAM;
3275 if ((this->version_id & 0xf) == 0xe)
3276 this->options |= ONENAND_HAS_NOP_1;
3278 this->options |= ONENAND_HAS_UNLOCK_ALL;
3283 if (!ONENAND_IS_DDP(this))
3284 this->options |= ONENAND_HAS_2PLANE;
3285 this->options |= ONENAND_HAS_UNLOCK_ALL;
3291 this->options |= ONENAND_HAS_UNLOCK_ALL;
3297 this->options |= ONENAND_HAS_CONT_LOCK;
3302 if (ONENAND_IS_MLC(this))
3303 this->options |= ONENAND_HAS_4KB_PAGE;
3305 if (ONENAND_IS_4KB_PAGE(this))
3306 this->options &= ~ONENAND_HAS_2PLANE;
3308 if (FLEXONENAND(this)) {
3309 this->options &= ~ONENAND_HAS_CONT_LOCK;
3310 this->options |= ONENAND_HAS_UNLOCK_ALL;
3313 if (this->options & ONENAND_HAS_CONT_LOCK)
3315 if (this->options & ONENAND_HAS_UNLOCK_ALL)
3317 if (this->options & ONENAND_HAS_2PLANE)
3319 if (this->options & ONENAND_HAS_4KB_PAGE)
3321 if (this->options & ONENAND_HAS_CACHE_PROGRAM)
3388 struct onenand_chip *this = mtd->priv;
3393 syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
3394 this->write_word((syscfg | 0x0100), this->base + ONENAND_REG_SYS_CFG1);
3396 for (die = 0; die < this->dies; die++) {
3397 this->command(mtd, FLEXONENAND_CMD_PI_ACCESS, die, 0);
3398 this->wait(mtd, FL_SYNCING);
3400 this->command(mtd, FLEXONENAND_CMD_READ_PI, die, 0);
3401 this->wait(mtd, FL_READING);
3403 bdry = this->read_word(this->base + ONENAND_DATARAM);
3408 this->boundary[die] = bdry & FLEXONENAND_PI_MASK;
3410 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3411 this->wait(mtd, FL_RESETTING);
3414 this->boundary[die], locked ? "(Locked)" : "(Unlocked)");
3418 this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
3429 struct onenand_chip *this = mtd->priv;
3434 density = onenand_get_density(this->device_id);
3435 blksperdie = ((loff_t)(16 << density) << 20) >> (this->erase_shift);
3436 blksperdie >>= ONENAND_IS_DDP(this) ? 1 : 0;
3438 eraseshift = this->erase_shift - 1;
3440 mtd->numeraseregions = this->dies << 1;
3446 for (; die < this->dies; die++) {
3447 if (!die || this->boundary[die-1] != maxbdry) {
3452 this->boundary[die] + 1;
3458 this->boundary[die] + 1;
3459 ofs += (this->boundary[die] + 1) << (eraseshift - 1);
3461 if (this->boundary[die] != maxbdry) {
3466 this->boundary[die];
3474 mtd->erasesize = 1 << this->erase_shift;
3486 for (die = 0, mtd->size = 0; die < this->dies; die++) {
3487 this->diesize[die] = (loff_t)blksperdie << this->erase_shift;
3488 this->diesize[die] -= (loff_t)(this->boundary[die] + 1)
3489 << (this->erase_shift - 1);
3490 mtd->size += this->diesize[die];
3505 * Avoid this by ensuring that the block to be converted is
3510 struct onenand_chip *this = mtd->priv;
3518 .oobbuf = this->oob_buf,
3525 addr = flexonenand_addr(this, block);
3538 if (this->oob_buf[i] != 0xff)
3558 struct onenand_chip *this = mtd->priv;
3563 if (die && (!ONENAND_IS_DDP(this)))
3567 if (boundary < 0 || boundary == this->boundary[die])
3570 density = onenand_get_density(this->device_id);
3571 blksperdie = ((16 << density) << 20) >> this->erase_shift;
3572 blksperdie >>= ONENAND_IS_DDP(this) ? 1 : 0;
3581 old = this->boundary[die] + (die * this->density_mask);
3582 new = boundary + (die * this->density_mask);
3590 this->command(mtd, FLEXONENAND_CMD_PI_ACCESS, die, 0);
3591 this->wait(mtd, FL_SYNCING);
3594 this->command(mtd, FLEXONENAND_CMD_READ_PI, die, 0);
3595 this->wait(mtd, FL_READING);
3597 thisboundary = this->read_word(this->base + ONENAND_DATARAM);
3607 addr = die ? this->diesize[0] : 0;
3612 this->command(mtd, ONENAND_CMD_ERASE, addr, 0);
3613 ret = this->wait(mtd, FL_ERASING);
3620 this->write_word(boundary, this->base + ONENAND_DATARAM);
3621 this->command(mtd, ONENAND_CMD_PROG, addr, 0);
3622 ret = this->wait(mtd, FL_WRITING);
3629 this->command(mtd, FLEXONENAND_CMD_PI_UPDATE, die, 0);
3630 ret = this->wait(mtd, FL_WRITING);
3632 this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_REG_COMMAND);
3633 this->wait(mtd, FL_RESETTING);
3650 struct onenand_chip *this = mtd->priv;
3655 syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
3657 this->write_word((syscfg & ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE), this->base + ONENAND_REG_SYS_CFG1);
3660 this->write_word(ONENAND_CMD_READID, this->base + ONENAND_BOOTRAM);
3663 bram_maf_id = this->read_word(this->base + ONENAND_BOOTRAM + 0x0);
3664 bram_dev_id = this->read_word(this->base + ONENAND_BOOTRAM + 0x2);
3667 this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_BOOTRAM);
3669 this->wait(mtd, FL_RESETTING);
3672 this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
3679 maf_id = this->read_word(this->base + ONENAND_REG_MANUFACTURER_ID);
3680 dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);
3695 struct onenand_chip *this = mtd->priv;
3700 ret = this->chip_probe(mtd);
3705 dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);
3706 ver_id = this->read_word(this->base + ONENAND_REG_VERSION_ID);
3707 this->technology = this->read_word(this->base + ONENAND_REG_TECHNOLOGY);
3711 this->device_id = dev_id;
3712 this->version_id = ver_id;
3718 if (FLEXONENAND(this)) {
3719 this->dies = ONENAND_IS_DDP(this) ? 2 : 1;
3721 mtd->numeraseregions = this->dies << 1;
3723 kcalloc(this->dies << 1,
3734 this->chipsize = (16 << density) << 20;
3738 mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE);
3740 if (ONENAND_IS_4KB_PAGE(this))
3751 if (FLEXONENAND(this))
3754 this->erase_shift = ffs(mtd->erasesize) - 1;
3755 this->page_shift = ffs(mtd->writesize) - 1;
3756 this->page_mask = (1 << (this->erase_shift - this->page_shift)) - 1;
3758 if (ONENAND_IS_DDP(this))
3759 this->density_mask = this->chipsize >> (this->erase_shift + 1);
3761 this->writesize = mtd->writesize;
3765 if (FLEXONENAND(this))
3768 mtd->size = this->chipsize;
3776 if (ONENAND_IS_2PLANE(this)) {
3799 struct onenand_chip *this = mtd->priv;
3801 if (this->state == FL_PM_SUSPENDED)
3821 struct onenand_chip *this = mtd->priv;
3823 if (!this->read_word)
3824 this->read_word = onenand_readw;
3825 if (!this->write_word)
3826 this->write_word = onenand_writew;
3828 if (!this->command)
3829 this->command = onenand_command;
3830 if (!this->wait)
3832 if (!this->bbt_wait)
3833 this->bbt_wait = onenand_bbt_wait;
3834 if (!this->unlock_all)
3835 this->unlock_all = onenand_unlock_all;
3837 if (!this->chip_probe)
3838 this->chip_probe = onenand_chip_probe;
3840 if (!this->read_bufferram)
3841 this->read_bufferram = onenand_read_bufferram;
3842 if (!this->write_bufferram)
3843 this->write_bufferram = onenand_write_bufferram;
3845 if (!this->block_markbad)
3846 this->block_markbad = onenand_default_block_markbad;
3847 if (!this->scan_bbt)
3848 this->scan_bbt = onenand_default_bbt;
3854 if (this->mmcontrol) {
3856 this->read_bufferram = onenand_sync_read_bufferram;
3860 if (!this->page_buf) {
3861 this->page_buf = kzalloc(mtd->writesize, GFP_KERNEL);
3862 if (!this->page_buf)
3865 this->verify_buf = kzalloc(mtd->writesize, GFP_KERNEL);
3866 if (!this->verify_buf) {
3867 kfree(this->page_buf);
3871 this->options |= ONENAND_PAGEBUF_ALLOC;
3873 if (!this->oob_buf) {
3874 this->oob_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
3875 if (!this->oob_buf) {
3876 if (this->options & ONENAND_PAGEBUF_ALLOC) {
3877 this->options &= ~ONENAND_PAGEBUF_ALLOC;
3879 kfree(this->verify_buf);
3881 kfree(this->page_buf);
3885 this->options |= ONENAND_OOBBUF_ALLOC;
3888 this->state = FL_READY;
3889 init_waitqueue_head(&this->wq);
3890 spin_lock_init(&this->chip_lock);
3897 if (FLEXONENAND(this)) {
3904 if (ONENAND_IS_NOP_1(this))
3926 this->subpagesize = mtd->writesize >> mtd->subpage_sft;
3941 mtd->type = ONENAND_IS_MLC(this) ? MTD_MLCNANDFLASH : MTD_NANDFLASH;
3968 if (!(this->options & ONENAND_SKIP_INITIAL_UNLOCKING))
3969 this->unlock_all(mtd);
3972 this->badblockpos = ONENAND_BADBLOCK_POS;
3974 ret = this->scan_bbt(mtd);
3975 if ((!FLEXONENAND(this)) || ret)
3992 struct onenand_chip *this = mtd->priv;
3998 if (this->bbm) {
3999 struct bbm_info *bbm = this->bbm;
4001 kfree(this->bbm);
4004 if (this->options & ONENAND_PAGEBUF_ALLOC) {
4005 kfree(this->page_buf);
4007 kfree(this->verify_buf);
4010 if (this->options & ONENAND_OOBBUF_ALLOC)
4011 kfree(this->oob_buf);