设为首页 加入收藏

TOP

Nandflash 驱动移植(三)
2013-01-13 10:31:52 来源: 作者: 【 】 浏览:1786
Tags:Nandflash  驱动 移植


  靠别人都行的话,母猪都会上树啦!咱还是自己搞吧!
  在上面UINT32    NFMLCBITPT;    //0x40 的后面添加以下代码:
  [cpp]  //0x44-- 8位ECC错误状态0寄存器
  UINT32    NF8ECCERR1;  //0x48-- 8位ECC错误状态1寄存器
  UINT32    NF8ECCERR2;  //0x4c-- 8位ECC错误状态2寄存器
  UINT32    NFM8ECC0;        //0x50-- 生成8位ECC状态0寄存器
  UINT32    NFM8ECC1;        //0x54-- 生成8位ECC状态1寄存器
  UINT32    NFM8ECC2;        //0x58-- 生成8位ECC状态2寄存器
  UINT32    NFM8ECC3;        //0x5c-- 生成8位ECC状态3寄存器
  UINT32    NFMLC8BITPT0;        //0x60-- 8位ECC错误位模式寄存器0
  UINT32    NFMLC8BITPT1;        //0x64-- 8位ECC错误位模式寄存器1
  nand.h文件:
  [cpp]
  //
  // Copyright (c) Microsoft Corporation.  All rights reserved.
  //
  //
  // Use of this sample source code is subject to the terms of the Microsoft
  // license agreement under which you licensed this sample source code. If
  // you did not accept the terms of the license agreement, you are not
  // authorized to use this sample source code. For the terms of the license,
  // please see the license agreement between you and Microsoft or, if applicable,
  // see the LICENSE.RTF on your install media or the root of your tools installation.
  // THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
  //
  #ifndef __NAND_H__
  #define __NAND_H__
  //-----------------------------------------------------------------------------
  typedef struct
  {
  UINT16 nNumOfBlks;
  UINT16 nPagesPerBlk;
  UINT16 nSctsPerPage;
  } NANDDeviceInfo;
  NANDDeviceInfo stDeviceInfo;
  #ifdef __cplusplus
  extern "C"  {
  #endif
  NANDDeviceInfo GetNandInfo(void);
  #ifdef __cplusplus
  }
  #endif
  #define NUM_OF_BLOCKS        (stDeviceInfo.nNumOfBlks)
  #define PAGES_PER_BLOCK    (stDeviceInfo.nPagesPerBlk)
  #define SECTORS_PER_PAGE    (stDeviceInfo.nSctsPerPage)
  #undef SECTOR_SIZE
  #define SECTOR_SIZE            (512)
  #define NAND_SECTOR_SIZE    (SECTOR_SIZE*SECTORS_PER_PAGE)
  #define NAND_PAGE_SIZE      (SECTOR_SIZE*SECTORS_PER_PAGE)  //< Physical Page Size
  #define IS_LB                ((SECTORS_PER_PAGE == 4)||(SECTORS_PER_PAGE == 8))
  //-----------------------------------------------------------------------------
  #define USE_NFCE            (0)
  #define USE_GPIO            (0)
  #define TACLS                (NAND_TACLS)
  #define TWRPH0                (NAND_TWRPH0)
  #define TWRPH1                (NAND_TWRPH1)
  #define ECCType                 (23)
  //-----------------------------------------------------------------------------
  #define CMD_READID            (0x90)    //  ReadID
  #define CMD_READ            (0x00)    //  Read
  #define CMD_READ2            (0x50)    //  Read2
  #define CMD_READ3            (0x30)    //  Read3
  #define CMD_RESET            (0xff)    //  Reset
  #define CMD_ERASE            (0x60)    //  Erase phase 1
  #define CMD_ERASE2            (0xd0)    //  Erase phase 2
  #define CMD_WRITE            (0x80)    //  Write phase 1
  #define CMD_WRITE2            (0x10)    //  Write phase 2
  #define CMD_STATUS            (0x70)    //  STATUS
  #define CMD_RDI                (0x85)    //  Random Data Input
  #define CMD_RDO                (0x05)    //  Random Data Output
  #define CMD_RDO2            (0xE0)    //  Random Data Output
  #define BADBLOCKMARK        (0x00)
  //  Status bit pattern
  #define STATUS_READY        (0x40)    //  Ready
  #define STATUS_ERROR        (0x01)    //  Error
  #define STATUS_ILLACC        (0x20)    // Illigar Access
  #define NF_ECCERR0_ALL_FF    0x40000000
  #define NF_ECCERR0_ECC_READY    0x20000000
  //-----------------------------------------------------------------------------
  #define NF_CMD(cmd)                {g_pNFConReg->NFCMD   =  (unsigned char)(cmd);}
  #define NF_ADDR(addr)            {g_pNFConReg->NFADDR  =  (unsigned char)(addr);}
  #define NF_nFCE_L()                {g_pNFConReg->NFCONT &= ~(1《1);}
  #define NF_nFCE_H()                {g_pNFConReg->NFCONT |=  (1《1);}
  #define NF_ECC_DIRECTION_IN()         {g_pNFConReg->NFCONT &= ~(1《18);}
  #define NF_ECC_DIRECTION_OUT()        {g_pNFConReg->NFCONT |= (1《18);}
  #define NF_ECC_8BIT_STOP()            {g_pNFConReg->NFCONT |= (1《12);} //stop the last encode or decode of 8bit mode.
  #define NF_RSTECC()                 {g_pNFConReg->NFCONT |=  ((1《5) | (1《4));}
  #define NF_MSGLENGTH_512()     {g_pNFConReg->NFCONF &= ~(1《25);}
  #define NF_MSGLENGTH_24()      {g_pNFConReg->NFCONF |= (1《25);}
  #define NF_ECCTYPE_CLR         (g_pNFConReg->NFCONF &= ~(3《23))
  #define NF_ECCTYPE_1BIT()      {NF_ECCTYPE_CLR;}
  #define NF_ECCTYPE_4BIT()      {NF_ECCTYPE_CLR |= (1《24);}
  #define NF_ECCTYPE_8BIT()      {NF_ECCTYPE_CLR |= (1《23);}
  #define NF_MECC_UnLock()        {g_pNFConReg->NFCONT &= ~(1《7);}
  #define NF_MECC_Lock()            {g_pNFConReg->NFCONT |= (1《7);}
  #define NF_SECC_UnLock()        {g_pNFConReg->NFCONT &= ~(1《6);}
  #define NF_SECC_Lock()            {g_pNFConReg->NFCONT |= (1《6);}
  #define NF_CLEAR_RB()            {g_pNFConReg->NFSTAT |=  (1《4);}                // Have write '1' to clear this bit.
  #define NF_DETECT_RB()            {while((g_pNFConReg->NFSTAT&0x11)!=0x11);}        // RnB_Transdetect & RnB
  #define NF_WAITRB()                {while (!(g_pNFConReg->NFSTAT & (1《0))) ; }
  #define NF_RDDATA_BYTE()        (g_pNFConReg->NFDATA)
  #define NF_RDDATA_WORD()        (*(UINT32 *)0xb0200010)
  #define NF_WRDATA_BYTE(data)    {g_pNFConReg->NFDATA  =  (UINT8)(data);}
  #define NF_WRDATA_WORD(data)    {*(UINT32 *)0xb0200010  =  (UINT32)(data);}
  #define NF_RDMECC0()            (g_pNFConReg->NFMECC0)
  #define NF_RDMECC1()            (g_pNFConReg->NFMECC1)
  #define NF_RDSECC()                (g_pNFConReg->NFSECC)
  #define NF_RDM8ECC0()            (g_pNFConReg->NFM8ECC0)
  #define NF_RDM8ECC1()            (g_pNFConReg->NFM8ECC1)
  #define NF_RDM8ECC2()            (g_pNFConReg->NFM8ECC2)
  #define NF_RDM8ECC3()            (g_pNFConReg->NFM8ECC3)
  #define NF_RDMECCD0()            (g_pNFConReg->NFMECCD0)
  #define NF_RDMECCD1()            (g_pNFConReg->NFMECCD1)
  #define NF_RDSECCD()            (g_pNFConReg->NFSECCD)
  #define NF_ECC_ERR0                (g_pNFConReg->NFECCERR0)
  #define NF_ECC_ERR1                (g_pNFConReg->NFECCERR1)
  #define NF_ECC8BIT_NUM                  ((g_pNFConReg->NF8ECCERR0 & (0xf《25))》25)
  #define NF_ECC8LOCATION_BYTE1           (g_pNFConReg->NF8ECCERR0 & (0x3ff))
  #define NF_ECC8LOCATION_BYTE2           ((g_pNFConReg->NF8ECCERR0 & (0x3ff《15))》15)
  #define NF_ECC8LOCATION_BYTE3           (g_pNFConReg->NF8ECCERR1 & (0x3ff))
  #define NF_ECC8LOCATION_BYTE4           ((g_pNFConReg->NF8ECCERR1 & (0x3ff《11))》11)
  #define NF_ECC8LOCATION_BYTE5           ((g_pNFConReg->NF8ECCERR1 & (0x3ff《22))》22)
  #define NF_ECC8LOCATION_BYTE6           (g_pNFConReg->NF8ECCERR2 & (0x3ff))
  #define NF_ECC8LOCATION_BYTE7           ((g_pNFConReg->NF8ECCERR2 & (0x3ff《11))》11)
  #define NF_ECC8LOCATION_BYTE8           ((g_pNFConReg->NF8ECCERR2 & (0x3ff《22))》22)
  #define NF_ECC8LOCATION_BIT(n)          (n <= 4)?((g_pNFConReg->NFMLC8BITPT0 & (0xff《((n-1)*8)))》((n-1)*8)):((g_pNFConReg->NFMLC8BITPT1 & (0xff《((n-5)*8)))》((n-5)*8))
  #define NF_ECC4BIT_NUM                  ((g_pNFConReg->NFECCERR0 & (0x7《26))》26)
  #define NF_ECC4LOCATION_BYTE(n)         ((n <= 2)?((g_pNFConReg->NFECCERR0 & (0x3ff《((n-1)*16)))》((n-1)*16)):((g_pNFConReg->NFECCERR1 & (0x3ff《((n-3)*16)))》((n-3)*16)))
  #define NF_ECC4LOCATION_BIT(n)          ((g_pNFConReg->NFMLCBITPT & (0xff《((n-1)*8)))》((n-1)*8))
  #define NF_WRMECCD0(data)        {g_pNFConReg->NFMECCD0 = (data);}
  #define NF_WRMECCD1(data)        {g_pNFConReg->NFMECCD1 = (data);}
  #define NF_WRSECCD(data)        {g_pNFConReg->NFSECCD = (data);}
  #define NF_RDSTAT                (g_pNFConReg->NFSTAT)
  //-----------------------------------------------------------------------------
  typedef enum
  {
  ECC_CORRECT_MAIN = 0,    // correct Main ECC
  ECC_CORRECT_SPARE1 = 1,     // correct Spare for Sector Info using Main ECC Result Area
  ECC_CORRECT_SPARE2 = 2,     // correct Spare for MECC using Main ECC Result Area
  ECC_CORRECT_SPARE = 3       // correct Spare using Spare ECC Result Area
  } ECC_CORRECT_TYPE;
  //-----------------------------------------------------------------------------
  #endif    // __NAND_H_.
  nand.h文件里有8bit ECC的相关定义,不要高兴的太早,这里面是有错滴,不知道是不是飞凌那边故意搞错的,还是本来就不是6410的。

          

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 3/7/7
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇简单c++序列化 下一篇AOE网中关键路径的一般求法

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: