/* --------------------------------------------------------------------------
FILE : nand.c
PURPOSE : NAND driver file
PROJECT : DaVinci User Boot-Loader and Flasher
AUTHOR : Daniel Allred
DESC : Generic NAND driver file for DaVinci EMIFA peripheral
-------------------------------------------------------------------------- */
// General type include
#include "tistdtypes.h"
// This module's header file
#include "nand.h"
// Device specific CSL
#include "device.h"
// Device NAND specific stuff
#include "device_nand.h"
// Misc. utility function include
#include "util.h"
// Project specific debug functionality
#include "debug.h"
/************************************************************
* Explicit External Declarations *
************************************************************/
// The device specific table of supported NAND devices
extern NAND_CHIP_InfoObj DEVICE_NAND_CHIP_infoTable[];
// The device specific ECC info struct
extern NAND_ECC_InfoObj DEVICE_NAND_ECC_info;
// The device specific BB info struct
extern NAND_BB_InfoObj DEVICE_NAND_BB_info;
// The device specific PAGE layout structure
extern NAND_PAGE_LayoutObj DEVICE_NAND_PAGE_layout;
/************************************************************
* Local Macro Declarations *
************************************************************/
/************************************************************
* Local Function Declarations *
************************************************************/
// Low-level NAND functions read, write, and command functions
static VUint8 *LOCAL_flashMakeAddr (Uint32 baseAddr, Uint32 offset);
static void LOCAL_flashWriteData(NAND_InfoHandle hNandInfo, Uint32 offset, Uint32 data);
static Uint32 LOCAL_flashReadData(NAND_InfoHandle hNandInfo);
// Address byte write functions
static void LOCAL_flashWriteColAddrBytes(NAND_InfoHandle hNandInfo, Uint32 offset);
static void LOCAL_flashWriteRowAddrBytes(NAND_InfoHandle hNandInfo, Uint32 page);
#ifndef USE_IN_ROM
// Array data writing functions
static void LOCAL_flashWriteBytes (NAND_InfoHandle hNandInfo, void *pSrc, Uint32 numBytes);
// Function to erase a block
static Uint32 LOCAL_eraseBlock(NAND_InfoHandle hNandInfo, Uint32 block, Bool force);
#endif
// Array data reading functions
static void LOCAL_flashReadBytes(NAND_InfoHandle hNandInfo, void *pDest, Uint32 numBytes);
// Wait for ready signal seen at NANDFSCR
static Uint32 LOCAL_flashWaitForRdy(Uint32 timeout);
// Wait for status result from device to read good
static Uint32 LOCAL_flashWaitForStatus(NAND_InfoHandle hNandInfo, Uint32 timeout);
// page Pointer set function
static Uint32 LOCAL_setPagePtr(NAND_InfoHandle hNandInfo,NAND_RegionType regtionType, Uint32 opNum);
// Get Chip details
static Uint32 LOCAL_flashGetDetails(NAND_InfoHandle hNandInfo);
// ONFI CRC check for Read Parameter Page command
static Bool LOCAL_onfiParamPageCRCCheck(Uint8 *paramPageData);
/************************************************************
* Local Variable Definitions *
************************************************************/
/************************************************************
* Global Variable Definitions *
************************************************************/
#ifdef USE_IN_ROM
NAND_InfoObj gNandInfo;
#endif
/************************************************************
* Global Function Definitions *
************************************************************/
// Initialze NAND interface and find the details of the NAND used
NAND_InfoHandle NAND_open(Uint32 baseCSAddr)
{
NAND_InfoHandle hNandInfo;
// Set NandInfo handle
#ifdef USE_IN_ROM
hNandInfo = (NAND_InfoHandle) &gNandInfo;
#else
hNandInfo = (NAND_InfoHandle) UTIL_allocMem(sizeof(NAND_InfoObj));
#endif
// Set NAND flash base address
hNandInfo->flashBase = baseCSAddr;
// Init the current block number and good flag
hNandInfo->currBlock = -1;
hNandInfo->isBlockGood = FALSE;
// Use device specific page layout and ECC layout
hNandInfo->hPageLayout = &DEVICE_NAND_PAGE_layout;
hNandInfo->hEccInfo = &DEVICE_NAND_ECC_info;
hNandInfo->hBbInfo = &DEVICE_NAND_BB_info;
hNandInfo->hChipInfo = DEVICE_NAND_CHIP_infoTable;
// Get the CSOffset ( can be 0 through (DEVICE_EMIF_NUMBER_CE_REGION -1) )
hNandInfo->CSOffset = 0;
while (hNandInfo->CSOffset < DEVICE_EMIF_NUMBER_CE_REGION)
{
if ( hNandInfo->flashBase ==
(DEVICE_EMIF_FIRST_CE_START_ADDR +
(DEVICE_EMIF_INTER_CE_REGION_SIZE * hNandInfo->CSOffset) ) )
{
break;
}
hNandInfo->CSOffset++;
}
if (hNandInfo->CSOffset == DEVICE_EMIF_NUMBER_CE_REGION)
return NULL;
// Set EMIF bus width
hNandInfo->busWidth = (Uint8) DEVICE_emifBusWidth();
// Setup AEMIF registers for NAND
AEMIF->NANDFCR &= ~(3 << 4);
AEMIF->NANDFCR |= hNandInfo->CSOffset << 4;
AEMIF->NANDFCR |= (0x1 << (hNandInfo->CSOffset)); // NAND enable for CSx
(*hNandInfo->hEccInfo->fxnEnable)(hNandInfo);
// Send reset command to NAND
if ( NAND_reset(hNandInfo) != E_PASS )
return NULL;
// Get and set device details
if ( LOCAL_flashGetDetails(hNandInfo) != E_PASS )
return NULL;
// Send reset command to NAND
if ( NAND_reset(hNandInfo) != E_PASS )
return NULL;
return hNandInfo;
}
// Routine to check a particular block to see if it is good or bad
Uint32 NAND_badBlockCheck(NAND_InfoHandle hNandInfo, Uint32 block)
{
Uint8 spareBytes[256];
if (!hNandInfo->hBbInfo->BBCheckEnable)
{
return E_PASS;
}
else if (hNandInfo->currBlock != block)
{
hNandInfo->currBlock = block;
// Read and check spare bytes of first page of block (ONFI and normal)
NAND_readSpareBytesOfPage(hNandInfo, block, 0, spareBytes);
if ((*hNandInfo->hBbInfo->fxnBBCheck)(hNandInfo,spareBytes) != E_PASS)
{
hNandInfo->isBlockGood = FALSE;
return E_FAIL;
}
// Read and check spare bytes of second page of block (normal)
NAND_readSpareBytesOfPage(hNandInfo, block, 1, spareBytes);
if ((*hNandInfo->hBbInfo->fxnBBCheck)(hNandInfo,spareBytes) != E_PASS)
{
hNandInfo->isBlockGood = FALSE;
return E_FAIL;
}
if (hNandInfo->isONFI)
{
// Read and check spare bytes of last page of block (for ONFI)
NAND_readSpareBytesOfPage(hNandInfo, block, (hNandInfo->pagesPerBlock - 1), spareBytes);
if ((*hNandInfo->hBbInfo->fxnBBCheck)(hNandInfo,spareBytes) != E_PASS)
{
hNandInfo->isBlockGood = FALSE;
return E_FAIL;
}
}
hNandInfo->isBlockGood = TRUE;
return E_PASS;
}
else if (hNandInfo->isBlockGood == FALSE)
{
return E_FAIL;
}
else
{
return E_PASS;
}
}
// Routine to reset the NAND device
Uint32 NAND_reset(NAND_InfoHandle hNandInfo)
{
// Send reset command to NAND
LOCAL_flashWriteData(hNandInfo, DEVICE_NAND_CLE_OFFSET, NAND_RESET );
return LOCAL_flashWaitForRdy(NAND_TIMEOUT);
}
// Routine to read a page from NAND
Uint32 NAND_readPage(NAND_InfoHandle hNandInfo, Uint32 block, Uint32 page, Uint8 *dest)
{
Uint32 i, currPagePtr, nextPagePtr;
//FIXME: the size of this array should be determined by the calcECCByteCnt
Uint8 readECC[16];
// This is enough to support 8 Kbyte page devices
Uint8 spareBytes[256];
// Get spare bytes of page (includes all stored ECC data)
NAND_readSpareBytesOfPage(hNandInfo,block,page,spareBytes);
// Write read co
没有合适的资源?快使用搜索试试~ 我知道了~
TI OMAP-L137 dsp程序列程
共290个文件
obj:60个
c:42个
h:25个
4星 · 超过85%的资源 需积分: 10 44 下载量 24 浏览量
2010-04-14
12:55:10
上传
评论 2
收藏 1.12MB RAR 举报
温馨提示
TI新出的双核CPU含一个arm926的核(主频300MHz);及一个浮点的dsp6747核(主频300MHz);这是我验证过的程序;好东西哦;
资源推荐
资源详情
资源评论
收起资源包目录
TI OMAP-L137 dsp程序列程 (290个子文件)
build.bat 393B
cleanup.bat 112B
nand.c 41KB
device.c 22KB
nandflash_test.c 21KB
gpio_test_OLD.c 20KB
emac_test.c 18KB
gpio_test.c 17KB
nandwriter.c 14KB
device_nand.c 13KB
mmcsd_protocol.c 11KB
DEC137_init.c 11KB
evmomapl137_i2c.c 8KB
mmcsd_evm.c 8KB
evmomapl137_uart.c 6KB
evmomapl137_led.c 6KB
util.c 6KB
evmomapl137_i2cgpio.c 6KB
AD_master_test.c 6KB
l137_leds.c 5KB
evmomapl137.c 5KB
sd_test.c 5KB
AD_slave_test.c 4KB
pwm.c 4KB
evmomapl137_gpio.c 4KB
evmomapl137_rtc.c 4KB
debug.c 4KB
evmomapl137_eeprom.c 3KB
evmomapl137_dip.c 3KB
emac_isr.c 2KB
uart_test.c 2KB
main.c 2KB
sdram_test.c 2KB
main.c 2KB
main.c 2KB
main.c 2KB
main.c 1KB
rtc_test.c 1KB
DA_test.c 1KB
main.c 910B
main.c 730B
main.c 688B
main.c 302B
Makefile.c 274B
SYMBOL.CDX 117KB
SYMBOL.CDX 72KB
SYMBOL.CDX 69KB
SYMBOL.CDX 68KB
SYMBOL.CDX 62KB
SYMBOL.CDX 61KB
SYMBOL.CDX 61KB
SYMBOL.CDX 60KB
SYMBOL.CDX 56KB
SYMBOL.CDX 56KB
SYMBOL.CDX 55KB
SYMBOL.CDX 54KB
FILE.CDX 3KB
FILE.CDX 3KB
FILE.CDX 3KB
FILE.CDX 3KB
FILE.CDX 3KB
FILE.CDX 3KB
FILE.CDX 3KB
FILE.CDX 3KB
FILE.CDX 3KB
FILE.CDX 3KB
FILE.CDX 3KB
FILE.CDX 3KB
linker.cmd 907B
linker.cmd 697B
l137_leds.c~ 5KB
SYMBOL.DBF 84KB
SYMBOL.DBF 51KB
SYMBOL.DBF 46KB
SYMBOL.DBF 45KB
SYMBOL.DBF 39KB
SYMBOL.DBF 39KB
SYMBOL.DBF 39KB
SYMBOL.DBF 39KB
SYMBOL.DBF 38KB
SYMBOL.DBF 36KB
SYMBOL.DBF 35KB
SYMBOL.DBF 34KB
FILE.DBF 846B
FILE.DBF 808B
FILE.DBF 504B
FILE.DBF 504B
FILE.DBF 466B
FILE.DBF 428B
FILE.DBF 390B
FILE.DBF 390B
FILE.DBF 390B
FILE.DBF 390B
FILE.DBF 390B
FILE.DBF 352B
DRAM 0B
DRAM_PROG 0B
SYMBOL.FPT 155KB
SYMBOL.FPT 88KB
SYMBOL.FPT 80KB
共 290 条
- 1
- 2
- 3
资源评论
- wodeavr2013-01-10正是我想找的资料,先学习学习,多谢楼主分享。
- trench2014-07-21还不错。样例比较多
- ssaye2012-12-21没有点灯的程序!
- mandoline84272012-10-07这个例程和我买的合众达的OMAPL138的是一样的,都可以用的,只是我想找的USB接口的例程是没有的
北岛南风
- 粉丝: 96
- 资源: 23
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功