39 #define DUMMY_REGISTER  (0x1084)    45 #define HOST_SHARE_MEM_BASE             (0xd0000UL)    46 #define CORTUS_SHARE_MEM_BASE   (0x60000000UL)    47 #define NMI_SPI_FLASH_ADDR              (0x111c)    51 #define GET_UINT32(X,Y)                 (X[0+Y] + ((uint32)X[1+Y]<<8) + ((uint32)X[2+Y]<<16) +((uint32)X[3+Y]<<24))    52 #define SPI_FLASH_BASE                  (0x10200)    53 #define SPI_FLASH_MODE                  (SPI_FLASH_BASE + 0x00)    54 #define SPI_FLASH_CMD_CNT               (SPI_FLASH_BASE + 0x04)    55 #define SPI_FLASH_DATA_CNT              (SPI_FLASH_BASE + 0x08)    56 #define SPI_FLASH_BUF1                  (SPI_FLASH_BASE + 0x0c)    57 #define SPI_FLASH_BUF2                  (SPI_FLASH_BASE + 0x10)    58 #define SPI_FLASH_BUF_DIR               (SPI_FLASH_BASE + 0x14)    59 #define SPI_FLASH_TR_DONE               (SPI_FLASH_BASE + 0x18)    60 #define SPI_FLASH_DMA_ADDR              (SPI_FLASH_BASE + 0x1c)    61 #define SPI_FLASH_MSB_CTL               (SPI_FLASH_BASE + 0x20)    62 #define SPI_FLASH_TX_CTL                (SPI_FLASH_BASE + 0x24)   103 #ifdef DISABLE_UNSED_FLASH_FUNCTIONS   112 static uint8 spi_flash_read_security_reg(
void)
   133         return (
sint8)reg & 0xff;
   143 static sint8 spi_flash_gang_unblock(
void)
   173 static sint8 spi_flash_clear_security_flags(
void)
   218         cmd[1] = (
uint8)(u32FlashAdr >> 16);
   219         cmd[2] = (
uint8)(u32FlashAdr >> 8);
   220         cmd[3] = (
uint8)(u32FlashAdr);
   256         cmd[1] = (
uint8)(u32FlashAdr >> 16);
   257         cmd[2] = (
uint8)(u32FlashAdr >> 8);
   258         cmd[3] = (
uint8)(u32FlashAdr);
   355         cmd[1] = (
uint8)(u32FlashAdr >> 16);
   356         cmd[2] = (
uint8)(u32FlashAdr >> 8);
   357         cmd[3] = (
uint8)(u32FlashAdr);
   439         unsigned char cmd[1];
   463         M2M_PRINT(
"Flash ID %x \n",(
unsigned int)reg);
   474 static void spi_flash_unlock(
void)
   477         tmp = spi_flash_read_security_reg();
   478         spi_flash_clear_security_flags();
   482                 spi_flash_gang_unblock();
   542         unsigned long long t1 = 0;
   551         u32off = u32Offset % u32Blksz;
   553         tpercent = (u32Sz/u32Blksz)+((u32Sz%u32Blksz)>0);
   554         t1 = GetTickCount64();
   559                 M2M_ERR(
"Data size = %d",(
int)u32Sz);
   566                 u32wsz = u32Blksz - u32off;
   572                 if (u32Sz < u32wsz) 
goto EXIT;
   579                 u32wsz = 
BSP_MIN(u32Sz, u32Blksz);
   592                 printf(
"\r>Complete Percentage = %d%%.\r",((percent*100)/tpercent));
   598         M2M_PRINT(
"\n#Programming time = %f sec\n\r",(GetTickCount64() - t1)/1000.0);
   622         unsigned long long t;
   623         t = GetTickCount64();
   625         M2M_DBG(
"\r\n>Start erasing...\r\n");
   626         for(i = u32Offset; i < (u32Sz +u32Offset); i += (16*
FLASH_PAGE_SZ))
   641         M2M_PRINT(
"#Erase time = %f sec\n", (GetTickCount64()-t)/1000.0);
   656         uint32 u32FlashId = 0, u32FlashPwr = 0;
   657         static uint32 gu32InernalFlashSize= 0;
   659         if(!gu32InernalFlashSize)
   662                 if(u32FlashId != 0xffffffff)
   665                         u32FlashPwr = ((u32FlashId>>16)&0xff) - 0x11; 
   667                         gu32InernalFlashSize = 1<<u32FlashPwr;
   668                         M2M_INFO(
"Flash Size %lu Mb\n",gu32InernalFlashSize);
   672                         M2M_ERR(
"Cann't Detect Flash size\n");
   676         return gu32InernalFlashSize;
 
#define SPI_FLASH_TR_DONE
 
#define SPI_FLASH_BUF_DIR
 
sint8 nm_read_block(uint32 u32Addr, uint8 *puBuf, uint32 u32Sz)
 
static uint32 spi_flash_rdid(void)
Read SPI Flash ID. 
 
signed char sint8
Range of values between -128 to 127. 
 
sint8 nm_read_reg_with_ret(uint32 u32Addr, uint32 *pu32RetVal)
 
sint8 nm_write_block(uint32 u32Addr, uint8 *puBuf, uint32 u32Sz)
 
static sint8 spi_flash_pp(uint32 u32Offset, uint8 *pu8Buf, uint16 u16Sz)
 
#define SPI_FLASH_DATA_CNT
 
unsigned short uint16
Range of values between 0 to 65535. 
 
static sint8 spi_flash_read_status_reg(uint8 *val)
 
static sint8 spi_flash_sector_erase(uint32 u32FlashAdr)
 
sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32offset, uint32 u32Sz)
Read a specified portion of data from SPI Flash. . 
 
uint32 spi_flash_get_size(void)
Returns with uint32 value which is total flash size . 
 
#define SPI_FLASH_CMD_CNT
 
sint8 spi_flash_erase(uint32 u32Offset, uint32 u32Sz)
Erase a specified portion of SPI Flash. . 
 
static sint8 spi_flash_load_to_cortus_mem(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 u32Sz)
 
sint8 nm_write_reg(uint32 u32Addr, uint32 u32Val)
 
static sint8 spi_flash_read_internal(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz)
 
#define SPI_FLASH_DMA_ADDR
 
unsigned long uint32
Range of values between 0 to 4294967295. 
 
#define HOST_SHARE_MEM_BASE
 
sint8 spi_flash_write(uint8 *pu8Buf, uint32 u32Offset, uint32 u32Sz)
Write a specified portion of data to SPI Flash. . 
 
unsigned char uint8
Range of values between 0 to 255. 
 
static sint8 spi_flash_page_program(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 u32Sz)
 
static sint8 spi_flash_write_disable(void)
Send write disable command to SPI flash. 
 
uint32 nm_read_reg(uint32 u32Addr)
 
static sint8 spi_flash_write_enable(void)
Send write enable command to SPI flash.