Definition in file nf.h.
#include "conf_nf.h"
#include "board.h"
#include "gpio.h"
#include "ecchrs.h"
#include "nf.h"
#include "nf_512B.h"
#include "nf_2KB.h"
Go to the source code of this file.
Data Structures | |
struct | St_nf_conf |
struct | St_nf_id |
struct | St_nf_link_id_block |
Defines | |
#define | _GLOBEXT_ extern |
#define | AVR32_EBI_NAND_FLASH_ADDRESS AVR32_EBI_CS3_ADDRESS |
#define | G_CACHE_PROG g_cache_program |
#define | G_CE_LOW g_ce_low |
#define | G_CLK_DFC_NFC g_clock_dfc_nfc |
#define | G_COPY_BACK_CONT g_copy_back_cont |
#define | G_COPY_BACK_DISCONT g_copy_back_discont |
#define | G_DEV_ID g_dev_id |
#define | G_DEV_MAKER g_dev_maker |
#define | G_N_BLOCKS g_n_blocks |
#define | G_N_ROW_CYCLES g_n_row_cycles |
#define | G_N_ZONES g_n_zones |
#define | G_OFST_BLK_STATUS g_ofst_blk_status |
#define | G_PROTECT_DEV (NF_PROTECTED_DEVICES) |
#define | G_SHIFT_BLOCK_PAGE g_shift_block_page |
#define | G_SHIFT_PAGE_BYTE g_shift_page_byte |
#define | Is_nf_2k() (11==g_shift_page_byte ) |
#define | Is_nf_512() ( 9==g_shift_page_byte ) |
#define | Is_not_nf_2k() (11!=g_shift_page_byte ) |
#define | Is_not_nf_512() ( 9!=g_shift_page_byte ) |
#define | M_ID_HYNIX 0xAD |
#define | M_ID_INFINEON 0xC1 |
#define | M_ID_MICRON 0x2C |
Resets the configuration state machine of the NFC. | |
#define | M_ID_SAMSUNG 0xEC |
#define | M_ID_SANDISK 0x98 |
#define | M_ID_ST 0x20 |
#define | M_ID_TOSHIBA 0x98 |
#define | M_ID_TOSHIBA96 0x96 |
#define | NF_AUTO_DETECT_2KB FALSE |
#define | NF_AUTO_DETECT_512B FALSE |
#define | NF_BAD_CONFIG (TRUE) |
#define | NF_BAD_CONFIG (TRUE) |
#define | NF_BAD_CONFIG (TRUE) |
#define | NF_BAD_CONFIG (TRUE) |
#define | NF_BAD_CONFIG FALSE |
#define | NF_BLOCK_ERASE_CMD 0x60 |
Erase command. | |
#define | NF_BLOCK_ERASE_CONFIRM_CMD 0xD0 |
Confirm erase command. | |
#define | NF_CACHE_PROGRAM_CMD 0x15 |
Cache program (fast) command (2KB). | |
#define | NF_COPY_BACK_CMD 0x35 |
Copy-back command (2KB). | |
#define | NF_DETECTION_ID (DISABLE) |
#define | nf_force_CE() |
#define | NF_GENERIC_DRIVER FALSE |
#define | NF_MASK_STATUS_FAIL (1<<0) |
Fail. | |
#define | NF_MASK_STATUS_READY (1<<6) |
Ready. | |
#define | NF_MASK_STATUS_T_RDY_2KB (1<<5) |
True Ready. | |
#define | NF_MASK_STATUS_T_RDY_512B (1<<6) |
True Ready. | |
#define | NF_MAX_DEVICES 4 |
#define | NF_N_GOOD_STATIC_BLOCK ( Is_nf_2k() ? 32 : 256 ) |
#define | Nf_open_page_read(page_addr, byte_addr) |
Opens a page for read. | |
#define | Nf_open_page_write(page_addr, byte_addr) |
Opens a page for write. | |
#define | NF_PAGE_PROGRAM_CMD 0x10 |
Page Program command. | |
#define | NF_RANDOM_DATA_INPUT_CMD 0x85 |
Random data input command (2KB). | |
#define | NF_RANDOM_READ_CMD_C1 0x05 |
Random read Command (2KB). | |
#define | NF_RANDOM_READ_CMD_C2 0xE0 |
Confirm random read Command (2KB). | |
#define | NF_READ_A_AREA_CMD 0x00 |
Read Command of zone A (512B). | |
#define | NF_READ_B_AREA_CMD 0x01 |
Read Command of zone B (512B). | |
#define | NF_READ_C_AREA_CMD 0x50 |
Read Command of zone C (spare) (512B). | |
#define | NF_READ_CMD 0x00 |
Read Command (2KB). | |
#define | NF_READ_CMD2 0x30 |
Confirm read Command (2KB). | |
#define | NF_READ_ID2_CMD 0x91 |
Read ID 2 Command. | |
#define | NF_READ_ID_CMD 0x90 |
Read ID Command. | |
#define | NF_READ_STATUS_CMD 0x70 |
Read Status command. | |
#define | NF_RESET_CMD 0xff |
Reset command. | |
#define | NF_SEQUENTIAL_DATA_INPUT_CMD 0x80 |
Sequential data input command. | |
#define | NF_SHIFT_SECTOR_BYTE 9 |
#define | NF_SPARE_POS ( Is_nf_2k() ? 2048 : 512 ) |
#define | nf_unforce_CE() |
#define | Nf_wait_cache_busy() |
Macro that tests the cache busy. | |
#define | NFC_BLK_ID_DATA 0xFF |
#define | NFC_BLK_ID_FBB 0xB4 |
#define | NFC_BLK_ID_QUARANTINE 0x8D |
#define | NFC_BLK_ID_RCV 0x72 |
#define | NFC_BLK_ID_SUBLUT 0xE8 |
#define | NFC_BLK_ID_SYSTEM 0x39 |
#define | NFC_OFST_3_DATA_DST 0xFF |
#define | NFC_OFST_3_DATA_SRC 0x00 |
#define | NFC_OFST_4_FBB_DRIVER_RELEASE 0x01 |
#define | NFC_OFST_6_FBB_INVALID 0 |
#define | NFC_OFST_6_FBB_VALID 0xFF |
#define | NFC_SPARE_DATA_INVALID 0 |
#define | NFC_SPARE_DATA_VALID 0xFF |
#define | NFC_SPARE_OFST_1_BLK_ID 1 |
#define | NFC_SPARE_OFST_2_BYTE_2 2 |
#define | NFC_SPARE_OFST_3_BYTE_3 3 |
#define | NFC_SPARE_OFST_4_BYTE_4 4 |
#define | NFC_SPARE_OFST_6_LBA 6 |
#define | NFC_SPARE_OFST_ECC1 13 |
#define | NFC_SPARE_OFST_ECC2 8 |
#define | NFC_SPARE_OFST_EXPORT 11 |
#define | SIZE_BLOCK_PAGE ((U8)1<<G_SHIFT_BLOCK_PAGE) |
#define | SIZE_PAGE_BYTE ((U16)1<<G_SHIFT_PAGE_BYTE) |
#define | SIZE_PAGE_SECTOR ((U8)1<<(G_SHIFT_PAGE_BYTE - S_SHIFT_SECTOR_BYTE)) |
#define | SIZE_SECTOR_BYTE ((U16)1<<S_SHIFT_SECTOR_BYTE) |
Functions | |
Bool | nf_check_status (void) |
Check the status of the selected device. | |
U8 | nf_check_type (U8 nb_dev) |
Tests the Nand Flash configuration. | |
void | nf_copy_back_conf (U32 page_addr) |
void | nf_copy_back_init (U32 page_addr) |
Prepare a copy-back session. | |
U8 | nf_detect (void) |
void | nf_erase_block (U32 page_addr, U8 force_erase) |
Erases a block. | |
U8 | nf_get_freq (void) |
returns the frequency supported by the selected NF. | |
void | nf_init (U32 hsb_f_hz) |
Initializes the Nand Flash Controller and low level driver. | |
void | nf_mark_bad_block (U32 page_addr) |
Mark a block as 'invalid' by clearing it entirely. | |
void | nf_open_page_read (U32 page_addr, U16 byte_addr) |
Opens a page for read. | |
void | nf_open_page_write (U32 page_addr, U16 byte_addr) |
Opens a page for write. | |
void | nf_print_block (U16 block_addr, U8 dev_id) |
void | nf_protect (void) |
Protect all the flashes. | |
static __inline__ U8 | nf_rd_data (void) |
Read a data byte from the Nand Flash. | |
U32 | nf_read_id (U8 read_id_cmd, U8 nf_num) |
Read the ID of the Nand-Flash. | |
void | nf_read_spare_byte (U8 _MEM_TYPE_SLOW_ *p_byte, U8 n_byte, U32 page_addr) |
void | nf_reset_nands (U8 nb_dev) |
Reset all the NF devices. | |
static __inline__ void | nf_select (U8 dev) |
Send a command cycle on the last selected Nand Flash. | |
static __inline__ void | nf_send_nop (void) |
Ensure that both CLE and ALE are not asserted. | |
void | nf_unprotect (void) |
unprotect all the flashes | |
void | nf_wait_busy (void) |
Tests the true busy. | |
static __inline__ void | nf_wr_addr (U8 addr) |
Send an address cycle on the last selected Nand Flash. | |
static __inline__ void | nf_wr_cmd (U8 cmd) |
Send a command cycle on the last selected Nand Flash. | |
static __inline__ void | nf_wr_data (U8 data) |
Write a data byte to the Nand Flash. | |
Variables | |
_GLOBEXT_ Bool | g_cache_program |
_GLOBEXT_ Bool | g_ce_low |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 | g_clock_dfc_nfc |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 | g_copy_back_cont |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 | g_copy_back_discont |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 | g_dev_id |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 | g_dev_maker |
_GLOBEXT_ _MEM_TYPE_SLOW_ U16 | g_n_blocks |
_GLOBEXT_ _MEM_TYPE_FAST_ U8 | g_n_row_cycles |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 | g_n_zones |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 | g_ofst_blk_status |
_GLOBEXT_ _MEM_TYPE_FAST_ U8 | g_shift_block_page |
_GLOBEXT_ _MEM_TYPE_FAST_ U8 | g_shift_page_byte |
#define AVR32_EBI_NAND_FLASH_ADDRESS AVR32_EBI_CS3_ADDRESS |
Definition at line 68 of file nf.h.
Referenced by nf_rd_data(), nf_wr_addr(), nf_wr_cmd(), and nf_wr_data().
#define G_CACHE_PROG g_cache_program |
#define G_CE_LOW g_ce_low |
#define G_CLK_DFC_NFC g_clock_dfc_nfc |
#define G_COPY_BACK_CONT g_copy_back_cont |
#define G_COPY_BACK_DISCONT g_copy_back_discont |
#define G_DEV_ID g_dev_id |
#define G_DEV_MAKER g_dev_maker |
#define G_N_BLOCKS g_n_blocks |
#define G_N_ROW_CYCLES g_n_row_cycles |
#define G_OFST_BLK_STATUS g_ofst_blk_status |
#define G_SHIFT_BLOCK_PAGE g_shift_block_page |
#define G_SHIFT_PAGE_BYTE g_shift_page_byte |
#define Is_nf_2k | ( | ) | (11==g_shift_page_byte ) |
#define Is_nf_512 | ( | ) | ( 9==g_shift_page_byte ) |
#define Is_not_nf_2k | ( | ) | (11!=g_shift_page_byte ) |
#define Is_not_nf_512 | ( | ) | ( 9!=g_shift_page_byte ) |
#define M_ID_MICRON 0x2C |
#define nf_force_CE | ( | ) |
#define NF_MAX_DEVICES 4 |
#define Nf_open_page_read | ( | page_addr, | |||
byte_addr | ) |
Opens a page for read.
The macro will adapt the commands according to the type of flash memory. The busy is polled at the end of the function.
page_addr | absolute page address of the block | |
byte_addr | relative byte address inside the page. |
nf_init()
should have been called before. The NF device should have been selected before with Nfc_action(NFC_ACT_DEV_SELECT, id)
. Definition at line 450 of file nf.h.
Referenced by nf_open_page_read().
#define Nf_open_page_write | ( | page_addr, | |||
byte_addr | ) |
Opens a page for write.
The macro will adapt the commands according to the type of flash memory.
page_addr | absolute page address of the block | |
byte_addr | relative byte address inside the page. |
nf_init()
should have been called before. The NF device should have been selected before with Nfc_action(NFC_ACT_DEV_SELECT, id)
. Definition at line 526 of file nf.h.
Referenced by nf_open_page_write().
#define NF_SPARE_POS ( Is_nf_2k() ? 2048 : 512 ) |
Definition at line 729 of file nf.h.
Referenced by main(), nf_erase_block(), nf_mark_bad_block(), and nfc_read_spare_byte().
#define Nf_wait_cache_busy | ( | ) |
Value:
{ \ ecchrs_freeze(&AVR32_ECCHRS); \ nf_wr_cmd(NF_READ_STATUS_CMD); \ while( (nf_rd_data() & NF_MASK_STATUS_READY)==0 /*busy*/ ); \ while( (nf_rd_data() & NF_MASK_STATUS_READY)==0 /*busy*/ ); \ ecchrs_unfreeze(&AVR32_ECCHRS); \ }
#define SIZE_PAGE_SECTOR ((U8)1<<(G_SHIFT_PAGE_BYTE - S_SHIFT_SECTOR_BYTE)) |
Bool nf_check_status | ( | void | ) |
Check the status of the selected device.
Definition at line 183 of file nf.c.
References NF_MASK_STATUS_FAIL, nf_rd_data(), and nf_wait_busy().
00184 { 00185 U8 data; 00186 nf_wait_busy(); // Send a status command and wait the completion of the last command 00187 00188 ecchrs_freeze(&AVR32_ECCHRS); 00189 data = nf_rd_data(); 00190 ecchrs_unfreeze(&AVR32_ECCHRS); 00191 if ( (data&NF_MASK_STATUS_FAIL)==0 ) { return PASS; } // I/O 0 Pass:0 Fail:1 00192 else { return FAIL; } 00193 }
U8 nf_check_type | ( | U8 | nb_dev | ) |
Tests the Nand Flash configuration.
The function verifies that the connected NF is properly declared in conf_nf.h.
nb_dev | number of device |
Definition at line 78 of file nf.c.
References G_CE_LOW, G_DEV_ID, G_DEV_MAKER, nf_force_CE, nf_rd_data(), NF_READ_ID_CMD, nf_reset_nands(), nf_select(), nf_wait_busy(), nf_wr_addr(), and nf_wr_cmd().
00079 { 00080 U8 i_dev; 00081 00082 //nf_init( nb_dev, 0 ); 00083 #warning Update for full support. 00084 nf_reset_nands( nb_dev ); // Reset all the NF devices 00085 00086 // Test NF configuration 00087 // 00088 for( i_dev=0 ; i_dev<nb_dev ; i_dev++ ) 00089 { 00090 nf_select( i_dev ); 00091 nf_wait_busy(); 00092 nf_force_CE(); 00093 nf_wr_cmd(NF_READ_ID_CMD); 00094 nf_wr_addr( 0 ); 00095 if(( nf_rd_data()!=G_DEV_MAKER ) 00096 || ( nf_rd_data()!=G_DEV_ID )) 00097 { 00098 Assert( FALSE ); 00099 return i_dev; 00100 } 00101 if( G_CE_LOW ) 00102 { 00103 // Activate CE Low if needed. This config is static 00104 // and we supposed that it is no more deactivated in firmware. 00105 nf_force_CE(); 00106 } 00107 } 00108 return nb_dev; 00109 }
void nf_copy_back_conf | ( | U32 | page_addr | ) |
void nf_copy_back_init | ( | U32 | page_addr | ) |
Prepare a copy-back session.
page_addr | absolute source page address of the block |
nf_init()
should have been called before. Definition at line 497 of file nf.c.
References G_N_ROW_CYCLES, NF_COPY_BACK_CMD, NF_READ_CMD, nf_wait_busy(), nf_wr_addr(), and nf_wr_cmd().
00498 { 00499 nf_wait_busy(); 00500 nf_wr_cmd(NF_READ_CMD); 00501 nf_wr_addr( 0 ); 00502 nf_wr_addr( 0 ); 00503 nf_wr_addr( LSB0(page_addr) ); 00504 nf_wr_addr( LSB1(page_addr) ); 00505 if ( 3==G_N_ROW_CYCLES ) 00506 { 00507 nf_wr_addr( MSB1(page_addr) ); 00508 } 00509 nf_wr_cmd(NF_COPY_BACK_CMD); 00510 nf_wait_busy(); 00511 }
U8 nf_detect | ( | void | ) |
void nf_erase_block | ( | U32 | page_addr, | |
U8 | force_erase | |||
) |
Erases a block.
The erase will be done only if the block is not bad
page_addr | absolute page address of the block | |
force_erase | TRUE forces erasing, FALSE erases the block (if not bad) |
nf_init()
should have been called before. The device which holds the block to delete should have been selected before with nf_select( id )
. Definition at line 275 of file nf.c.
References G_N_ROW_CYCLES, G_OFST_BLK_STATUS, NF_BLOCK_ERASE_CMD, NF_BLOCK_ERASE_CONFIRM_CMD, nf_open_page_read(), nf_rd_data(), NF_SPARE_POS, nf_wait_busy(), nf_wr_addr(), and nf_wr_cmd().
Referenced by main(), and nf_mark_bad_block().
00276 { 00277 if( FALSE==force_erase ) 00278 { 00279 nf_open_page_read( page_addr, NF_SPARE_POS + G_OFST_BLK_STATUS ); 00280 if( (nf_rd_data()!=0xFF) ) return; // The block is bad. We can not erase it 00281 } 00282 nf_wait_busy(); 00283 nf_wr_cmd(NF_BLOCK_ERASE_CMD); // Auto Block Erase Setup 00284 nf_wr_addr( LSB0(page_addr) ); 00285 nf_wr_addr( LSB1(page_addr) ); 00286 if ( 3==G_N_ROW_CYCLES ) 00287 { 00288 nf_wr_addr( MSB1(page_addr) ); 00289 } 00290 nf_wr_cmd(NF_BLOCK_ERASE_CONFIRM_CMD); // Erase command 00291 }
U8 nf_get_freq | ( | void | ) |
void nf_init | ( | U32 | hsb_f_hz | ) |
Initializes the Nand Flash Controller and low level driver.
hsb_f_hz | HSB frequency in Hertz |
Definition at line 137 of file nf.c.
References EBI_NANDOE, and EBI_NANDWE.
Referenced by main(), and nfc_detect().
00138 { 00139 static const gpio_map_t SMC_NF_EBI_GPIO_MAP = 00140 { 00141 {ATPASTE2(EBI_NANDOE,_PIN),ATPASTE2(EBI_NANDOE,_FUNCTION)}, 00142 {ATPASTE2(EBI_NANDWE,_PIN),ATPASTE2(EBI_NANDWE,_FUNCTION)}, 00143 }; 00144 00145 gpio_enable_module(SMC_NF_EBI_GPIO_MAP, sizeof(SMC_NF_EBI_GPIO_MAP) / sizeof(SMC_NF_EBI_GPIO_MAP[0])); 00146 smc_init(hsb_f_hz); 00147 00148 // Enable Nand Flash Chip Select 00149 AVR32_HMATRIX.sfr[AVR32_EBI_HMATRIX_NR] |= (1 << AVR32_EBI_NAND_CS); 00150 00151 /* 00152 Nfc_disable(); // Reset the macro 00153 Nfc_enable(); 00154 Nfc_ecc_disable(); 00155 Nfc_spzone_disable(); 00156 #if (defined NF_TIMING_READ) 00157 Nfc_set_read_timing( NF_TIMING_READ ); 00158 #endif 00159 */ 00160 }
void nf_mark_bad_block | ( | U32 | page_addr | ) |
Mark a block as 'invalid' by clearing it entirely.
page_addr | absolute page address of the block |
nf_init()
should have been called before. The device which holds this bad block should have been selected before with nf_select( id )
. Definition at line 232 of file nf.c.
References G_SHIFT_BLOCK_PAGE, Is_nf_512, nf_erase_block(), nf_open_page_write(), NF_PAGE_PROGRAM_CMD, NF_SPARE_POS, nf_wr_cmd(), and nf_wr_data().
00233 { 00234 U8 n_bytes; 00235 U8 i_byte; 00236 U8 i_page; 00237 00238 00239 n_bytes= ( Is_nf_512() ) 00240 ? 16 // 512B page access 00241 : 64 // 2KB page access 00242 ; 00243 // Erasing the block is mandatory to prevent partial programming 00244 // (some 512B NF does support partial prog, but not after a copy back command). 00245 nf_erase_block( page_addr, TRUE ); 00246 for ( i_page=(U8)1<<G_SHIFT_BLOCK_PAGE ; i_page!=0 ; i_page--, page_addr++ ) 00247 { 00248 nf_open_page_write( page_addr, NF_SPARE_POS-8 ); 00249 nf_wr_data('A'); nf_wr_data('t'); 00250 nf_wr_data('m'); nf_wr_data('e'); 00251 nf_wr_data('l'); nf_wr_data(' '); 00252 nf_wr_data(' '); nf_wr_data(' '); 00253 for ( i_byte=n_bytes ; i_byte!=0 ; i_byte-=4 ) 00254 { 00255 nf_wr_data(0); 00256 nf_wr_data(0); 00257 nf_wr_data(0); 00258 nf_wr_data(0); 00259 } 00260 nf_wr_cmd(NF_PAGE_PROGRAM_CMD); // Confirm programmation 00261 } 00262 }
void nf_open_page_read | ( | U32 | page_addr, | |
U16 | byte_addr | |||
) |
Opens a page for read.
The function will adapt the commands according to the type of flash memory. The busy is polled at the end of the function.
page_addr | absolute page address of the block | |
byte_addr | relative byte address inside the page. |
nf_init()
should have been called before. The NF device should have been selected before with nf_select( id )
. Definition at line 204 of file nf.c.
References Nf_open_page_read, and nf_wait_busy().
Referenced by main(), nf_erase_block(), and nfc_read_spare_byte().
00205 { 00206 nf_wait_busy(); 00207 Nf_open_page_read( page_addr, byte_addr); 00208 }
void nf_open_page_write | ( | U32 | page_addr, | |
U16 | byte_addr | |||
) |
Opens a page for write.
The function will adapt the commands according to the type of flash memory.
page_addr | absolute page address of the block | |
byte_addr | relative byte address inside the page. |
nf_init()
should have been called before. The NF device should have been selected before with nf_select( id )
. Definition at line 219 of file nf.c.
References Nf_open_page_write.
Referenced by main(), and nf_mark_bad_block().
00220 { 00221 Nf_open_page_write( page_addr, byte_addr); 00222 }
void nf_print_block | ( | U16 | block_addr, | |
U8 | dev_id | |||
) |
void nf_protect | ( | void | ) |
Protect all the flashes.
Definition at line 545 of file nf.c.
References NF_N_DEVICES, nf_select(), and nf_wait_busy().
00546 { 00547 U32 i_dev; 00548 00549 // Wait until the end of any pending internal programmation (Cache Program cmd). 00550 for( i_dev=0 ; i_dev<NF_N_DEVICES ; i_dev++ ) 00551 { 00552 nf_select( i_dev ); 00553 nf_wait_busy(); 00554 } 00555 gpio_clr_gpio_pin(NF_WP_PIN); 00556 }
static __inline__ U8 nf_rd_data | ( | void | ) | [static] |
Read a data byte from the Nand Flash.
Definition at line 75 of file nf.h.
References AVR32_EBI_NAND_FLASH_ADDRESS.
Referenced by main(), nf_check_status(), nf_check_type(), nf_erase_block(), nf_read_id(), nf_wait_busy(), and nfc_read_spare_byte().
00076 { 00077 volatile unsigned char *p_data = ((volatile unsigned char *)AVR32_EBI_NAND_FLASH_ADDRESS); 00078 return *p_data; 00079 }
U32 nf_read_id | ( | U8 | read_id_cmd, | |
U8 | nf_num | |||
) |
Read the ID of the Nand-Flash.
read_id_cmd | Read_id command (NF_READ_ID_CMD, NF_READ_ID2_CMD) | |
nf_num | Nand Flash number |
nf_init()
should have been called before. Definition at line 359 of file nf.c.
References nf_rd_data(), nf_select(), nf_wait_busy(), nf_wr_addr(), and nf_wr_cmd().
Referenced by main(), and nfc_detect().
00360 { 00361 U32 ret; 00362 00363 nf_select( nf_num ); 00364 nf_wait_busy(); 00365 //nf_force_CE(); 00366 nf_wr_cmd (read_id_cmd); 00367 nf_wr_addr( 0 ); 00368 00369 MSB0(ret)= nf_rd_data(); // Maker Code 00370 MSB1(ret)= nf_rd_data(); // Device Id 00371 MSB2(ret)= nf_rd_data(); // extra 00372 MSB3(ret)= nf_rd_data(); // extra (Multi Plane Support) 00373 00374 //Nfc_action( NFC_ACT_ASSERT_CE, NFC_EXT_NOP); 00375 return ret; 00376 }
void nf_read_spare_byte | ( | U8 _MEM_TYPE_SLOW_ * | p_byte, | |
U8 | n_byte, | |||
U32 | page_addr | |||
) |
void nf_reset_nands | ( | U8 | nb_dev | ) |
Reset all the NF devices.
nb_dev | Number of device |
Definition at line 117 of file nf.c.
References NF_RESET_CMD, nf_select(), nf_wait_busy(), and nf_wr_cmd().
Referenced by main(), nf_check_type(), and nfc_detect().
00118 { 00119 U8 i_dev; 00120 for( i_dev=0 ; i_dev<nb_dev ; i_dev++ ) 00121 { 00122 nf_select( i_dev ); 00123 // The wait is mandatory here since the function is used to wait any 00124 // pending internal programmation (Cache Program cmd). 00125 nf_wait_busy(); 00126 nf_wr_cmd(NF_RESET_CMD); 00127 nf_wait_busy(); 00128 } 00129 }
static __inline__ void nf_select | ( | U8 | dev | ) | [static] |
Send a command cycle on the last selected Nand Flash.
dev | Device number. |
Definition at line 145 of file nf.h.
Referenced by main(), nf_check_type(), nf_protect(), nf_read_id(), and nf_reset_nands().
00146 { 00147 if( dev==0 ) 00148 { 00149 #if (NF_N_DEVICES==2) || (NF_N_DEVICES==4) 00150 // Release all other CS 00151 gpio_set_gpio_pin(NF_DEV_1_CS_PIN); 00152 # if (NF_N_DEVICES==4) 00153 gpio_set_gpio_pin(NF_DEV_2_CS_PIN); 00154 gpio_set_gpio_pin(NF_DEV_3_CS_PIN); 00155 # endif 00156 #endif 00157 // Select device 00158 gpio_clr_gpio_pin(NF_DEV_0_CS_PIN); 00159 } 00160 #if (NF_N_DEVICES==2) || (NF_N_DEVICES==4) 00161 else if( dev==1 ) 00162 { 00163 // Release all other CS 00164 gpio_set_gpio_pin(NF_DEV_0_CS_PIN); 00165 # if (NF_N_DEVICES==4) 00166 gpio_set_gpio_pin(NF_DEV_2_CS_PIN); 00167 gpio_set_gpio_pin(NF_DEV_3_CS_PIN); 00168 # endif 00169 // Select device 00170 gpio_clr_gpio_pin(NF_DEV_1_CS_PIN); 00171 } 00172 # if (NF_N_DEVICES==4) 00173 else if( dev==2 ) 00174 { 00175 // Release all other CS 00176 gpio_set_gpio_pin(NF_DEV_0_CS_PIN); 00177 gpio_set_gpio_pin(NF_DEV_1_CS_PIN); 00178 gpio_set_gpio_pin(NF_DEV_3_CS_PIN); 00179 00180 // Select device 00181 gpio_clr_gpio_pin(NF_DEV_2_CS_PIN); 00182 } 00183 else if( dev==3 ) 00184 { 00185 // Release all other CS 00186 gpio_set_gpio_pin(NF_DEV_0_CS_PIN); 00187 gpio_set_gpio_pin(NF_DEV_1_CS_PIN); 00188 gpio_set_gpio_pin(NF_DEV_2_CS_PIN); 00189 00190 // Select device 00191 gpio_clr_gpio_pin(NF_DEV_3_CS_PIN); 00192 } 00193 # endif 00194 #endif 00195 }
static __inline__ void nf_send_nop | ( | void | ) | [static] |
Ensure that both CLE and ALE are not asserted.
Definition at line 97 of file nf.h.
Referenced by nf_wr_addr(), and nf_wr_cmd().
00098 { 00099 //volatile unsigned char *p_nop = (volatile unsigned char *)AVR32_EBI_NAND_FLASH_ADDRESS; 00100 volatile unsigned char *p_nop = (volatile unsigned char *)AVR32_EBI_CS0_ADDRESS; 00101 *p_nop = 0; 00102 }
void nf_unprotect | ( | void | ) |
void nf_wait_busy | ( | void | ) |
Tests the true busy.
Note that we test twice the ready, since there is an hardware minimum requirement between the end of the busy and the first read cycle. Since the busy is not wired, the ready is tested twice.
Definition at line 319 of file nf.c.
References G_CACHE_PROG, Is_nf_2k, Is_nf_512, NF_MASK_STATUS_READY, NF_MASK_STATUS_T_RDY_2KB, NF_MASK_STATUS_T_RDY_512B, nf_rd_data(), NF_READ_STATUS_CMD, and nf_wr_cmd().
Referenced by main(), nf_check_status(), nf_check_type(), nf_copy_back_init(), nf_erase_block(), nf_open_page_read(), nf_protect(), nf_read_id(), and nf_reset_nands().
00320 { 00321 ecchrs_freeze(&AVR32_ECCHRS); 00322 nf_wr_cmd(NF_READ_STATUS_CMD); 00323 if( Is_nf_2k() ) 00324 { 00325 if( G_CACHE_PROG ) 00326 { 00327 while( (nf_rd_data() & NF_MASK_STATUS_T_RDY_2KB )==0 ); 00328 while( (nf_rd_data() & NF_MASK_STATUS_T_RDY_2KB )==0 ); 00329 } 00330 else 00331 { 00332 while( (nf_rd_data() & NF_MASK_STATUS_READY )==0 ); 00333 while( (nf_rd_data() & NF_MASK_STATUS_READY )==0 ); 00334 } 00335 } 00336 if( Is_nf_512() ) 00337 { 00338 while( (nf_rd_data() & NF_MASK_STATUS_T_RDY_512B )==0 ); 00339 while( (nf_rd_data() & NF_MASK_STATUS_T_RDY_512B )==0 ); 00340 } 00341 ecchrs_unfreeze(&AVR32_ECCHRS); 00342 }
static __inline__ void nf_wr_addr | ( | U8 | addr | ) | [static] |
Send an address cycle on the last selected Nand Flash.
addr | address |
Definition at line 111 of file nf.h.
References AVR32_EBI_NAND_FLASH_ADDRESS, and nf_send_nop().
Referenced by nf_check_type(), nf_copy_back_init(), nf_erase_block(), and nf_read_id().
00112 { 00113 volatile int A; 00114 volatile unsigned char *p_ale = ((volatile unsigned char *)AVR32_EBI_NAND_FLASH_ADDRESS + 0x00400000); 00115 A=0; // If a access at AVR32_EBI_CS0_ADDRESS is done just BEFORE ALE address then the ALE is low in same time of WE rise (ALE hold time ~5ns) 00116 *p_ale = addr; 00117 A=0; // If a access at AVR32_EBI_CS0_ADDRESS is done just AFTER ALE address then the ALE is low in same time of WE rise (ALE hold time ~5ns) 00118 nf_send_nop(); 00119 }
static __inline__ void nf_wr_cmd | ( | U8 | cmd | ) | [static] |
Send a command cycle on the last selected Nand Flash.
cmd | command. |
Definition at line 128 of file nf.h.
References AVR32_EBI_NAND_FLASH_ADDRESS, and nf_send_nop().
Referenced by main(), nf_check_type(), nf_copy_back_init(), nf_erase_block(), nf_mark_bad_block(), nf_read_id(), nf_reset_nands(), nf_wait_busy(), and nfc_nf_is_ready().
00129 { 00130 volatile int A; 00131 volatile unsigned char *p_cle = ((volatile unsigned char *)AVR32_EBI_NAND_FLASH_ADDRESS + 0x00200000); 00132 A=0; // If an access at AVR32_EBI_CS0_ADDRESS is done just BEFORE CLE address then the CLE is low in same time of WE rise (CLE hold time ~5ns) 00133 *p_cle = cmd; 00134 A=0; // If an access at AVR32_EBI_CS0_ADDRESS is done just AFTER CLE address then the CLE is low in same time of WE rise (CLE hold time ~5ns) 00135 nf_send_nop(); 00136 }
static __inline__ void nf_wr_data | ( | U8 | data | ) | [static] |
Write a data byte to the Nand Flash.
Definition at line 86 of file nf.h.
References AVR32_EBI_NAND_FLASH_ADDRESS.
Referenced by main(), and nf_mark_bad_block().
00087 { 00088 volatile unsigned char *p_data = ((volatile unsigned char *)AVR32_EBI_NAND_FLASH_ADDRESS); 00089 *p_data=data; 00090 }
_GLOBEXT_ Bool g_cache_program |
_GLOBEXT_ Bool g_ce_low |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 g_clock_dfc_nfc |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 g_copy_back_cont |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 g_copy_back_discont |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 g_dev_id |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 g_dev_maker |
_GLOBEXT_ _MEM_TYPE_SLOW_ U16 g_n_blocks |
_GLOBEXT_ _MEM_TYPE_FAST_ U8 g_n_row_cycles |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 g_n_zones |
_GLOBEXT_ _MEM_TYPE_SLOW_ U8 g_ofst_blk_status |
_GLOBEXT_ _MEM_TYPE_FAST_ U8 g_shift_block_page |
_GLOBEXT_ _MEM_TYPE_FAST_ U8 g_shift_page_byte |