Files
vhdl/lib/CPUs/MIPS/bsp/examples/cfiflash.h
T
jens 034f28a4f6 - change names of block align functions
Committed on the Free edition of March Hare Software CVSNT Server.
Upgrade to CVS Suite for more features and support:
http://march-hare.com/cvsnt/


git-svn-id: http://moon:8086/svn/vhdl/trunk@542 cc03376c-175c-47c8-b038-4cd826a8556b
2009-10-27 23:32:09 +00:00

59 lines
1.8 KiB
C

/************************************************************************/
#ifndef CFIFLASH_H
#define CFIFLASH_H
#include "libsys.h"
#define SR_BIT_DPS 0x00020002
#define SR_BIT_PSS 0x00040004
#define SR_BIT_VPENS 0x00080008
#define SR_BIT_PSLBS 0x00100010
#define SR_BIT_ECLBS 0x00200020
#define SR_BIT_ESS 0x00400040
#define SR_BIT_ISMS 0x00800080
#define CFI_ERR_BASE (LSYS_ERR_BASE + 0x00100000)
#define CFI_ERR_GENERAL (CFI_ERR_BASE + 0)
#define CFI_ERR_NOTFOUND (CFI_ERR_BASE + 1)
#define CFI_ERR_INVPARAM (CFI_ERR_BASE + 2)
#define CFI_ERR_VFY_FAIL (CFI_ERR_BASE + 3)
#define CFI_ERR_DEV_FAIL (CFI_ERR_BASE + 0x10000000)
typedef struct _sflash_info_t
{
UINT32 flashsize;
UINT32 blocksize;
UINT32 nblocks;
UINT32 wbuf_size;
UINT32 if_width;
UINT32 num_flash;
} flash_info_t;
typedef struct _sflash_t
{
void *pBase;
UINT32 eb;
flash_info_t info;
} flash_t;
void cfi_init(flash_t *pObj, UINT32 base_addr);
UINT32 cfi_find(flash_t *pObj);
UINT32 cfi_block_is_locked(flash_t *pObj, UINT32 word_index);
UINT32 cfi_block_erase(flash_t *pObj, UINT32 word_index);
UINT32 cfi_block_lock(flash_t *pObj, UINT32 word_index);
UINT32 cfi_block_unlock(flash_t *pObj, UINT32 word_index);
UINT32 cfi_program_single(flash_t *pObj, UINT32 word_index, UINT32 word);
UINT32 cfi_program_multi(flash_t *pObj, UINT32 word_index, UINT32 *pWords, UINT32 num_words);
UINT32 flash_get_offset_by_blocknum(flash_t *pObj, UINT32 blocknum);
UINT32 flash_get_blocknum_by_offset(flash_t *pObj, UINT32 offset);
UINT32 flash_get_offset_blockaligned(flash_t *pObj, UINT32 offset);
UINT32 flash_find(flash_t *pObj, UINT32 base_addr);
UINT32 flash_erase(flash_t *pObj, UINT32 offset, UINT32 size);
UINT32 flash_program(flash_t *pObj, UINT32 offset, UINT8 *pData, UINT32 size);
UINT32 flash_verify(flash_t *pObj, UINT32 offset, UINT8 *pData, UINT32 size);
#endif // CFIFLASH_H