mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-01 14:14:38 +02:00
qi-improve-nand-read-512-granularity.patch
Previously we insisted on NAND block granularity read addressing and buffer length, even though we normalized the block indexing to 512 bytes to be compatible with ext2 and SD. This patch improves the read functions so they are completely 512- block friendly, any number of 512 byte blocks can be fetched from any 512 byte boundary now. Signed-off-by: Andy Green <andy@openmoko.com>
This commit is contained in:
parent
25b5a9ba62
commit
bb67ea1a84
@ -80,14 +80,18 @@ int s3c2442_nand_is_bad_block(unsigned long block_index)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nand_read_page_ll(unsigned char *buf, unsigned long block512)
|
static int nand_read_page_ll(unsigned char *buf, unsigned long block512, int blocks512)
|
||||||
{
|
{
|
||||||
unsigned short *ptr16 = (unsigned short *)buf;
|
unsigned short *ptr16 = (unsigned short *)buf;
|
||||||
unsigned int i, page_num;
|
unsigned int i, page_num;
|
||||||
#if 0
|
unsigned int block_amount;
|
||||||
unsigned char ecc[64];
|
int blocks_possible = (3 - (block512 & 3)) + 1;
|
||||||
unsigned short *p16 = (unsigned short *)ecc;
|
|
||||||
#endif
|
|
||||||
|
if (blocks512 > blocks_possible)
|
||||||
|
blocks512 = blocks_possible;
|
||||||
|
|
||||||
|
block_amount = (NAND_PAGE_SIZE / 4 / 2) * blocks512;
|
||||||
|
|
||||||
nand_clear_RnB();
|
nand_clear_RnB();
|
||||||
|
|
||||||
@ -96,23 +100,20 @@ static int nand_read_page_ll(unsigned char *buf, unsigned long block512)
|
|||||||
page_num = block512 >> 2; /* 512 block -> 2048 block */
|
page_num = block512 >> 2; /* 512 block -> 2048 block */
|
||||||
/* Write Address */
|
/* Write Address */
|
||||||
NFADDR = 0;
|
NFADDR = 0;
|
||||||
NFADDR = 0;
|
NFADDR = (block512 & 3) << 1; /* which 512 block in 2048 */
|
||||||
NFADDR = page_num & 0xff;
|
NFADDR = page_num & 0xff;
|
||||||
NFADDR = (page_num >> 8) & 0xff;
|
NFADDR = (page_num >> 8) & 0xff;
|
||||||
NFADDR = (page_num >> 16) & 0xff;
|
NFADDR = (page_num >> 16) & 0xff;
|
||||||
NFCMD = NAND_CMD_READSTART;
|
NFCMD = NAND_CMD_READSTART;
|
||||||
nand_wait();
|
nand_wait();
|
||||||
|
|
||||||
for (i = 0; i < NAND_PAGE_SIZE/2; i++)
|
for (i = 0; i < block_amount; i++)
|
||||||
*ptr16++ = NFDATA16;
|
*ptr16++ = NFDATA16;
|
||||||
#if 0
|
|
||||||
for (i = 0; i < 64 / 2; i++) {
|
return blocks512;
|
||||||
*p16++ = NFDATA16;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* low level nand read function */
|
/* low level nand read function */
|
||||||
int nand_read_ll(unsigned char *buf, unsigned long start_block512,
|
int nand_read_ll(unsigned char *buf, unsigned long start_block512,
|
||||||
int blocks512)
|
int blocks512)
|
||||||
@ -120,9 +121,6 @@ int nand_read_ll(unsigned char *buf, unsigned long start_block512,
|
|||||||
int i, j;
|
int i, j;
|
||||||
int bad_count = 0;
|
int bad_count = 0;
|
||||||
|
|
||||||
if (start_block512 & 3) /* inside 2048-byte block */
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* chip Enable */
|
/* chip Enable */
|
||||||
nand_select();
|
nand_select();
|
||||||
nand_clear_RnB();
|
nand_clear_RnB();
|
||||||
@ -140,7 +138,7 @@ int nand_read_ll(unsigned char *buf, unsigned long start_block512,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
j = nand_read_page_ll(buf, start_block512);
|
j = nand_read_page_ll(buf, start_block512, blocks512);
|
||||||
start_block512 += j;
|
start_block512 += j;
|
||||||
buf += j << 9;
|
buf += j << 9;
|
||||||
blocks512 -= j;
|
blocks512 -= j;
|
||||||
|
Loading…
Reference in New Issue
Block a user