Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 27756
b: refs/heads/master
c: 9c01f87
h: refs/heads/master
v: v3
  • Loading branch information
Kyungmin Park authored and Jarkko Lavinen committed May 12, 2006
1 parent 23e79bc commit 929f529
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 628bee6593107c466e28462f58c5fd5cd4163c7c
refs/heads/master: 9c01f87db183403a4f603fe5180c57b82b54b4a1
38 changes: 38 additions & 0 deletions trunk/drivers/mtd/onenand/onenand_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/mtd/onenand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 929f529

Please sign in to comment.