smc.h
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:7k
源码类别:

DVD

开发平台:

C/C++

  1. /**************************************************************************
  2.  *                                                                        *
  3.  *         Copyright (c) 2002 by Sunplus Technology Co., Ltd.             *
  4.  *                                                                        *
  5.  *  This software is copyrighted by and is the property of Sunplus        *
  6.  *  Technology Co., Ltd. All rights are reserved by Sunplus Technology    *
  7.  *  Co., Ltd. This software may only be used in accordance with the       *
  8.  *  corresponding license agreement. Any unauthorized use, duplication,   *
  9.  *  distribution, or disclosure of this software is expressly forbidden.  *
  10.  *                                                                        *
  11.  *  This Copyright notice MUST not be removed or modified without prior   *
  12.  *  written consent of Sunplus Technology Co., Ltd.                       *
  13.  *                                                                        *
  14.  *  Sunplus Technology Co., Ltd. reserves the right to modify this        *
  15.  *  software without notice.                                              *
  16.  *                                                                        *
  17.  *  Sunplus Technology Co., Ltd.                                          *
  18.  *  19, Innovation First Road, Science-Based Industrial Park,             *
  19.  *  Hsin-Chu, Taiwan, R.O.C.                                              *
  20.  *                                                                        *
  21.  *  Author:         modify by wthsin ,040106                              *
  22.  *                                                                        *
  23.  **************************************************************************/
  24. /*--------------------------------------------------------------------------
  25. |  File Name   :  smc.h
  26. |
  27. |  Description :  SmartMedia Card Interface
  28. |
  29. |  Version    :  0.1  
  30. |  Rev Date         Author(s)      Status & Comments
  31. |---------------------------------------------------------------------------------
  32. |  0.1 2004/3/3         wthsin         Creating
  33. |--------------------------------------------------------------------------------*/  
  34. #ifndef _SMC_H_
  35. #define _SMC_H_
  36. #define SMC_SUCCESS   0
  37. #define SMC_FAIL    1 
  38. #define IS_ERASE      1
  39. #define NOT_ERASE     0
  40. #define NAND_TIMEOUT  0x02
  41. #define NAND_READY    0x01 
  42. #define MAND_DATA_RD  0x200
  43. #define MAND_DATA_WR  0x100
  44. #define SMC_BLK_STS_GOOD_ONES     6
  45. #define NAND_BLK_STS_GOOD_ONES    8
  46. #define SMC_DATA_STS_GOOD_ONES    4
  47. #define IS_NAND_SMALL_BLKS        0
  48. #define IS_NAND_UNKNOWN           1
  49. #define IS_NAND_BIG_BLKS          2
  50. #define SMC_DEV_ID_4M_1           0xe3
  51. #define SMC_DEV_ID_4M_2           0xe5
  52. #define SMC_DEV_ID_8M             0xe6
  53. #define SMC_DEV_ID_16M            0x73
  54. #define SMC_DEV_ID_32M            0x75
  55. #define SMC_DEV_ID_64M            0x76
  56. #define SMC_DEV_ID_128M           0x79
  57. #define NAND_DEV_ID_128M_1        0xa1
  58. #define NAND_DEV_ID_128M_2        0xf1
  59. #define NAND_DEV_ID_256M_1        0xaa
  60. #define NAND_DEV_ID_256M_2        0xda
  61. #define NAND_DEV_ID_512M_1        0xac
  62. #define NAND_DEV_ID_512M_2        0xdc
  63. #define XD_DEV_ID_256M            0x71
  64. #define XD_DEV_ID_512M            0xDC
  65. #define XD_DEV_ID_1G              0xD3
  66. #define XD_DEV_ID_2G              0xD5
  67. #define LOG_BLOCK_NUM_PER_ZONE    1000
  68. #define PHY_BLOCK_NUM_PER_ZONE    1024
  69. const UINT8 CIS_Page[]={0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02, 0xDF, 0x01, 0x20}; //Card Information System
  70. const UINT8 smcOnesLookupTable[16] = {
  71.           /* 0b00 0b01 0b10 0b11 */
  72. /* 0b00 */      0,   1,   1,   2,
  73. /* 0b01 */      1,   2,   2,   3,
  74. /* 0b10 */      1,   2,   2,   3,
  75. /* 0b11 */      2,   3,   3,   4
  76. };
  77. typedef struct   
  78. {
  79. UINT8     makerId;
  80.     UINT8     devId;
  81. UINT16    pageSize; 
  82. UINT8     pageBit;
  83. UINT32    blkSize;  
  84. UINT8     nrBitPagesPerBlk;
  85. UINT32    nrBlks;  
  86. UINT8     addrCycle;  
  87. UINT8     eccCnt;  
  88. UINT8     redundBytes;
  89. UINT8     isXD; 
  90. } smcDev_t;
  91. typedef struct 
  92. {
  93. UINT8 reserved[4];
  94. UINT8 dataSts;
  95. UINT8 blkSts;
  96. UINT8 blkAddr1[2];
  97. UINT8 ecc2[3];
  98. UINT8 blkAddr2[2];
  99. UINT8 ecc1[3];
  100. } redundArea_t;
  101. //-------------------------------------------------------------------------------------------------
  102. // Memory space define
  103. //-------------------------------------------------------------------------------------------------
  104. #define SMC_TABLE_ADDR                 (SDRAM_BASE_UNCACHED + (A_JPEG_SERVO_YA)*1024)   
  105. #define SMC_TABLE_BUF_SIZE      0x00008000  // 32k
  106. #define SMC_ZONE_TABLE_ADDR            (SDRAM_BASE_UNCACHED + CARD_YA*1024)   
  107. #define SMC_ZONE_TABLE_BUF_SIZE     0x00000800  // 2k
  108. #define SMC_BAD_BLOCK_TABLE_ADDR       (SMC_TABLE_ADDR + SMC_TABLE_BUF_SIZE)  
  109. #define SMC_BAD_BLOCK_TABLE_BUF_SIZE 0x00000080  // 128 Byte
  110. #define SMC_SMALL_TABLE_ADDR           (SMC_BAD_BLOCK_TABLE_ADDR + SMC_BAD_BLOCK_TABLE_BUF_SIZE)  
  111. #define SMC_SMALL_TABLE_BUF_SIZE 0x00000020  // 16*2 Byte
  112. #define SMC_REDUNDANT_BUF_POINTER    (SMC_SMALL_TABLE_ADDR + SMC_SMALL_TABLE_BUF_SIZE)
  113. #define SMC_REDUNDANT_BUF_SIZE     0x00000010  // 16 byte
  114. /**************************************************************************
  115.  *                              M A C R O S                               *
  116.  **************************************************************************/
  117. #define hwNandPioReady()            while((regs0->ndData&0x100) != 0x100) 
  118. #ifndef HDMI_SMC_CLE 
  119. #define hwDisableNandInterface()    (regs0->ndCtrl[0] = 0x03) // CLE:0  ALE:0  /WP:1  /CE:1
  120. #endif
  121. #define HW_ECC_MODE_SET(mode)       (regs0->eccMode = mode)  
  122. #define HW_ECC_CLEAR()              (regs0->eccReset = 0x01)  
  123. /**************************************************************************
  124.  *               F U N C T I O N    D E C L A R A T I O N S               *
  125.  **************************************************************************/
  126. extern void   hwNandTimeInit(UINT32  ,UINT32  ,UINT32 ,UINT32);
  127. extern void   hwNandCmdSend(UINT8  );
  128. extern UINT32 hwNandRdyCheck();
  129. extern void   hwNandAddrSend(UINT8  ,UINT32  ,UINT32  );
  130. extern void   hwNandIdRead();
  131. extern UINT8  hwNandPortRead();
  132. extern UINT32 smcDetect();
  133. extern UINT32 smcLbaFieldCalc(UINT32);
  134. extern UINT32 smcLbaCalc(UINT8 ,UINT8 );
  135. extern UINT8  smcParityCheck(UINT8 ,UINT8);
  136. extern void   smcRedundRead(UINT32 ,UINT8 *);
  137. extern UINT32 smcDmaRead(UINT32 ,UINT32 ,UINT8 *);
  138. extern UINT32 hwNandEccVerify(UINT8 *);
  139. extern UINT32 smcPageCorrect(UINT8 *,UINT8 *,UINT8 *);
  140. extern UINT32 smcBlkErase(UINT32);
  141. extern UINT32 smcDmaWrite(UINT32 ,UINT32 ,UINT8 *,UINT32);
  142. //extern void   smcMakeZoneTable(UINT8);
  143. extern void   smcMakeTable();
  144. extern void   hwNandEccFill();
  145. extern UINT32 smcRead(UINT32,UINT32,UINT8 *);
  146. #endif /* _SMC_H_ */