[MTD] OneNAND: Handle DDP chip boundary during read-while-load

The read-while-load method of reading from OneNAND needs to allow
for the change of bufferRAM address at the boundary between the
two chips in a double density (DDP) device.

Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

authored by Adrian Hunter and committed by Artem Bityutskiy 0fc2ccea b3c9f8bf

+14 -1
+14 -1
drivers/mtd/onenand/onenand_base.c
··· 710 710 struct mtd_ecc_stats stats; 711 711 int read = 0, column; 712 712 int thislen; 713 - int ret = 0; 713 + int ret = 0, boundary = 0; 714 714 715 715 DEBUG(MTD_DEBUG_LEVEL3, "onenand_read: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len); 716 716 ··· 749 749 from += thislen; 750 750 if (read + thislen < len) { 751 751 this->command(mtd, ONENAND_CMD_READ, from, mtd->writesize); 752 + /* 753 + * Chip boundary handling in DDP 754 + * Now we issued chip 1 read and pointed chip 1 755 + * bufferam so we have to point chip 0 bufferam. 756 + */ 757 + if (this->device_id & ONENAND_DEVICE_IS_DDP && 758 + unlikely(from == (this->chipsize >> 1))) { 759 + this->write_word(0, this->base + ONENAND_REG_START_ADDRESS2); 760 + boundary = 1; 761 + } else 762 + boundary = 0; 752 763 ONENAND_SET_PREV_BUFFERRAM(this); 753 764 } 754 765 /* While load is going, read from last bufferRAM */ ··· 769 758 if (read == len) 770 759 break; 771 760 /* Set up for next read from bufferRAM */ 761 + if (unlikely(boundary)) 762 + this->write_word(0x8000, this->base + ONENAND_REG_START_ADDRESS2); 772 763 ONENAND_SET_NEXT_BUFFERRAM(this); 773 764 buf += thislen; 774 765 thislen = min_t(int, mtd->writesize, len - read);