1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-26 01:10:18 +02:00

cleanup code style

This commit is contained in:
Xiangfu Liu 2010-12-23 18:07:30 +08:00
parent eb283a6f70
commit 24aa5a2277

View File

@ -61,9 +61,10 @@ static volatile unsigned char *addrport = (volatile unsigned char *)0xb8010000;
static volatile unsigned char *dataport = (volatile unsigned char *)0xb8000000; static volatile unsigned char *dataport = (volatile unsigned char *)0xb8000000;
static volatile unsigned char *cmdport = (volatile unsigned char *)0xb8008000; static volatile unsigned char *cmdport = (volatile unsigned char *)0xb8008000;
static int bus = 8, row = 2, pagesize = 2048, oobsize = 64, ppb = 128; static int bus, row, pagesize, oobsize, ppb;
static int bad_block_pos, bad_block_page, force_erase, ecc_pos, wp_pin; static int bad_block_pos, bad_block_page, force_erase, ecc_pos, wp_pin;
static u8 oob_buf[256] = {0}; static u8 oob_buf[256] = {0};
extern struct hand Hand; extern struct hand Hand;
extern u16 handshake_PKT[4]; extern u16 handshake_PKT[4];
@ -77,8 +78,10 @@ static unsigned int EMC_CSN[4] = {
static inline void __nand_sync(void) static inline void __nand_sync(void)
{ {
unsigned int timeout = 100000; unsigned int timeout = 100000;
while ((REG_GPIO_PXPIN(2) & 0x40000000) && timeout--); while ((REG_GPIO_PXPIN(2) & 0x40000000) && timeout--)
while (!(REG_GPIO_PXPIN(2) & 0x40000000)); ;
while (!(REG_GPIO_PXPIN(2) & 0x40000000))
;
} }
static void select_chip(int block) static void select_chip(int block)
@ -86,6 +89,7 @@ static void select_chip(int block)
int t; int t;
if (!Hand.nand_bpc) if (!Hand.nand_bpc)
return; return;
t = (block / Hand.nand_bpc) % 4; t = (block / Hand.nand_bpc) % 4;
addrport = (volatile unsigned char *)(EMC_CSN[t] + 0x10000); addrport = (volatile unsigned char *)(EMC_CSN[t] + 0x10000);
dataport = (volatile unsigned char *)EMC_CSN[t]; dataport = (volatile unsigned char *)EMC_CSN[t];
@ -133,11 +137,11 @@ unsigned int nand_query_4740(u8 *id)
__nand_cmd(CMD_READID); __nand_cmd(CMD_READID);
__nand_addr(0); __nand_addr(0);
id[0] = __nand_data8(); //VID id[0] = __nand_data8(); /* VID */
id[1] = __nand_data8(); //PID id[1] = __nand_data8(); /* PID */
id[2] = __nand_data8(); //CHIP ID id[2] = __nand_data8(); /* CHIP ID */
id[3] = __nand_data8(); //PAGE ID id[3] = __nand_data8(); /* PAGE ID */
id[4] = __nand_data8(); //PLANE ID id[4] = __nand_data8(); /* PLANE ID */
return 0; return 0;
} }
@ -163,9 +167,9 @@ int nand_init_4740(int bus_width, int row_cycle, int page_size, int page_per_blo
} }
nand_init_gpio(); nand_init_gpio();
select_chip(0); select_chip(0);
REG_EMC_SMCR1 = 0x0fff7700; //slow speed REG_EMC_SMCR1 = 0x0fff7700; /* slow speed */
// REG_EMC_SMCR1 = 0x04444400; //normal speed /* REG_EMC_SMCR1 = 0x04444400; normal speed */
// REG_EMC_SMCR1 = 0x0d221200; //fast speed /* REG_EMC_SMCR1 = 0x0d221200; fast speed */
if (bus == 8) { if (bus == 8) {
write_proc = nand_data_write8; write_proc = nand_data_write8;
@ -174,6 +178,7 @@ int nand_init_4740(int bus_width, int row_cycle, int page_size, int page_per_blo
write_proc = nand_data_write16; write_proc = nand_data_write16;
read_proc = nand_data_read16; read_proc = nand_data_read16;
} }
return 0; return 0;
} }
@ -267,7 +272,7 @@ u32 nand_read_raw_4740(void *buf, u32 startpage, u32 pagecount, int option)
select_chip(cnt / ppb); select_chip(cnt / ppb);
if ((cur_page % ppb) == 0) { if ((cur_page % ppb) == 0) {
if (nand_check_block(cur_page / ppb)) { if (nand_check_block(cur_page / ppb)) {
cur_page += ppb; //Bad block, set to next block cur_page += ppb; /* Bad block, set to next block */
continue; continue;
} }
} }
@ -435,7 +440,7 @@ u32 nand_read_4740(void *buf, u32 startpage, u32 pagecount, int option)
if ((cur_page % ppb) == 0) { if ((cur_page % ppb) == 0) {
cur_blk = cur_page / ppb; cur_blk = cur_page / ppb;
if (nand_check_block(cur_blk)) { if (nand_check_block(cur_blk)) {
cur_page += ppb; //Bad block, set to next block cur_page += ppb; /* Bad block, set to next block */
continue; continue;
} }
} }
@ -570,7 +575,7 @@ restart:
if ((cur % ppb) == 0) { if ((cur % ppb) == 0) {
if (nand_check_block(cur / ppb)) { if (nand_check_block(cur / ppb)) {
cur += ppb; // Bad block, set to next block cur += ppb; /* Bad block, set to next block */
continue; continue;
} }
} }
@ -604,9 +609,9 @@ restart:
switch (option) { switch (option) {
case OOB_ECC: case OOB_ECC:
write_proc(tmpbuf, pagesize); //write data write_proc(tmpbuf, pagesize); /* write data */
tmpbuf += pagesize; tmpbuf += pagesize;
write_proc((u8 *)tmpbuf, oobsize); //write oob write_proc((u8 *)tmpbuf, oobsize); /* write oob */
tmpbuf += oobsize; tmpbuf += oobsize;
break; break;
@ -683,7 +688,7 @@ restart:
/* page program error */ /* page program error */
if (__nand_data8() & 0x01) { if (__nand_data8() & 0x01) {
serial_puts("Skip a write fail block\n"); serial_puts("Skip a write fail block\n");
nand_erase_4740(1, cur/ppb, 1); //force erase before nand_erase_4740(1, cur/ppb, 1); /* force erase before */
nand_mark_bad_4740(cur / ppb); nand_mark_bad_4740(cur / ppb);
spage += ppb; spage += ppb;
goto restart; goto restart;
@ -710,7 +715,7 @@ static u32 nand_mark_bad_page(u32 page)
if (wp_pin) if (wp_pin)
__gpio_set_pin(wp_pin); __gpio_set_pin(wp_pin);
//all set to 0x00 /* all set to 0x00 */
for (i = 0; i < pagesize + oobsize; i++) for (i = 0; i < pagesize + oobsize; i++)
badbuf[i] = 0x00; badbuf[i] = 0x00;
@ -739,8 +744,8 @@ u32 nand_mark_bad_4740(int block)
{ {
u32 rowaddr; u32 rowaddr;
//nand_erase_4740( 1, block, 1); //force erase before /* nand_erase_4740( 1, block, 1); force erase before */
if ( bad_block_page >= ppb ) { //mark four page! if (bad_block_page >= ppb) { /* mark four page! */
rowaddr = block * ppb + 0; rowaddr = block * ppb + 0;
nand_mark_bad_page(rowaddr); nand_mark_bad_page(rowaddr);
@ -752,7 +757,7 @@ u32 nand_mark_bad_4740(int block)
rowaddr = block * ppb + ppb - 1; rowaddr = block * ppb + ppb - 1;
nand_mark_bad_page(rowaddr); nand_mark_bad_page(rowaddr);
} else { //mark one page only } else { /* mark one page only */
rowaddr = block * ppb + bad_block_page; rowaddr = block * ppb + bad_block_page;
nand_mark_bad_page(rowaddr); nand_mark_bad_page(rowaddr);
} }