]> err.no Git - linux-2.6/commitdiff
OneNAND: handle byte access on BufferRAM
authorKyungmin Park <kyungmin.park@samsung.com>
Fri, 12 May 2006 14:02:31 +0000 (17:02 +0300)
committerJarkko Lavinen <lavinen@pentafluge.infradead.org>
Fri, 12 May 2006 14:35:45 +0000 (15:35 +0100)
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
drivers/mtd/onenand/onenand_base.c
include/linux/mtd/onenand.h

index d6c13f7ae5a1f82d23b80c6e6e634e440755b741..1439c9fa1d23bd51e6dfdd814e76f910eb1fde1e 100644 (file)
@@ -373,6 +373,17 @@ static int onenand_read_bufferram(struct mtd_info *mtd, int area,
 
        bufferram += onenand_bufferram_offset(mtd, area);
 
+       if (ONENAND_CHECK_BYTE_ACCESS(count)) {
+               unsigned short word;
+
+               /* Align with word(16-bit) size */
+               count--;
+
+               /* Read word and save byte */
+               word = this->read_word(bufferram + offset + count);
+               buffer[count] = (word & 0xff);
+       }
+
        memcpy(buffer, bufferram + offset, count);
 
        return 0;
@@ -400,6 +411,17 @@ static int onenand_sync_read_bufferram(struct mtd_info *mtd, int area,
 
        this->mmcontrol(mtd, ONENAND_SYS_CFG1_SYNC_READ);
 
+       if (ONENAND_CHECK_BYTE_ACCESS(count)) {
+               unsigned short word;
+
+               /* Align with word(16-bit) size */
+               count--;
+
+               /* Read word and save byte */
+               word = this->read_word(bufferram + offset + count);
+               buffer[count] = (word & 0xff);
+       }
+
        memcpy(buffer, bufferram + offset, count);
 
        this->mmcontrol(mtd, 0);
@@ -427,6 +449,22 @@ static int onenand_write_bufferram(struct mtd_info *mtd, int area,
 
        bufferram += onenand_bufferram_offset(mtd, area);
 
+       if (ONENAND_CHECK_BYTE_ACCESS(count)) {
+               unsigned short word;
+               int byte_offset;
+
+               /* Align with word(16-bit) size */
+               count--;
+
+               /* Calculate byte access offset */
+               byte_offset = offset + count;
+
+               /* Read word and save byte */
+               word = this->read_word(bufferram + byte_offset);
+               word = (word & ~0xff) | buffer[count];
+               this->write_word(word, bufferram + byte_offset);
+       }
+
        memcpy(bufferram + offset, buffer, count);
 
        return 0;
index 7419b5fab1337a8f55899f219e2d297faef5a064..22322c8a7729da6984ef36994a3a9ae0d8cb57a4 100644 (file)
@@ -130,6 +130,9 @@ struct onenand_chip {
 #define ONENAND_SET_SYS_CFG1(v, this)                                  \
        (this->write_word(v, this->base + ONENAND_REG_SYS_CFG1))
 
+/* Check byte access in OneNAND */
+#define ONENAND_CHECK_BYTE_ACCESS(addr)                (addr & 0x1)
+
 /*
  * Options bits
  */