/** page_mode : 0, small page ; 1 large page */ STATIC_PREFIX int nf_send_read_cmd(unsigned page_off,unsigned page_mode) { while (NFC_CMDFIFO_SIZE() > 15); NFC_SEND_CMD_CLE(CE0,0); //Send NAND read start command NFC_SEND_CMD_ALE(CE0,0); // Send Address if(page_mode) NFC_SEND_CMD_ALE(CE0,0); NFC_SEND_CMD_ALE(CE0,page_off&0xff); NFC_SEND_CMD_ALE(CE0,(page_off&0xff00)>>8); NFC_SEND_CMD_ALE(CE0,(page_off&0xff0000)>>16); if(page_mode) NFC_SEND_CMD_CLE(CE0,0x30); /** waiting for tWB **/ NFC_SEND_CMD_IDLE(CE0,5); // tWB NFC_SEND_CMD_RB(CE0,14); if(((NFC_INFO_GET()>>26)&1)) { serial_puts("BUG RB CMD\n"); while(!((NFC_INFO_GET()>>26)&1)); } NFC_SEND_CMD_IDLE(CE0,0); while (NFC_CMDFIFO_SIZE() > 0); // all cmd is finished return 0; }
void nf_erase(void) { int i; nf_cntl_init(romboot_info); for(i=0;i<4;i++) { NFC_SEND_CMD_CLE(CE0,0x60); NFC_SEND_CMD_ALE(CE0,0); NFC_SEND_CMD_ALE(CE0,i); NFC_SEND_CMD_ALE(CE0,0); NFC_SEND_CMD_CLE(CE0,0xd0); NFC_SEND_CMD_RB(CE0,0); } NFC_SEND_CMD_IDLE(CE0,0); // FIFO cleanup NFC_SEND_CMD_IDLE(CE0,0); // FIFO cleanup while(NFC_CMDFIFO_SIZE()>0); // wait until all command is finished }
STATIC_PREFIX void nf_reset(t_nf_ce ce) { NFC_SEND_CMD(1<<31); NFC_SEND_CMD_IDLE(ce,0); // FIFO cleanup NFC_SEND_CMD_CLE(ce,0xff); //Send reset command NFC_SEND_CMD_IDLE(ce,10); //Wait tWB NFC_SEND_CMD_RB(ce,15); //Wait Busy Signal NFC_SEND_CMD_IDLE(ce,0); // FIFO cleanup NFC_SEND_CMD_IDLE(ce,0); // FIFO cleanup while(NFC_CMDFIFO_SIZE()>0) // wait until all command is finished { if(NFC_CHECEK_RB_TIMEOUT()) // RB time out break; } while(!((NFC_INFO_GET()>>26)&1)); }