smc_phy.c
上传用户:yj_qqy
上传日期:2017-01-28
资源大小:2911k
文件大小:22k
源码类别:

uCOS

开发平台:

C/C++

  1. /*
  2. **********************************************************************
  3. *                          Micrium, Inc.
  4. *                      949 Crestview Circle
  5. *                     Weston,  FL 33327-1848
  6. *
  7. *                            uC/FS
  8. *
  9. *             (c) Copyright 2001 - 2003, Micrium, Inc.
  10. *                      All rights reserved.
  11. *
  12. ***********************************************************************
  13. ----------------------------------------------------------------------
  14. File        : smc_phy.c
  15. Purpose     : SMC generic physical media access
  16. ----------------------------------------------------------------------
  17. Known problems or limitations with current version
  18. ----------------------------------------------------------------------
  19. None.
  20. ---------------------------END-OF-HEADER------------------------------
  21. */
  22. /*********************************************************************
  23. *
  24. *             #include Section
  25. *
  26. **********************************************************************
  27. */
  28. #include "fs_port.h"
  29. #include "fs_dev.h"
  30. #include "fs_conf.h"
  31. #if FS_USE_SMC_DRIVER
  32. #include "smc.h"
  33. #include "smc_x_hw.h"
  34. /*********************************************************************
  35. *
  36. *             #define constants
  37. *
  38. **********************************************************************
  39. */
  40. #define EVEN             0          /* Even Page for 256byte/page */
  41. #define ODD              1          /* Odd  Page for 256byte/page */
  42. /*********************************************************************
  43. *
  44. *             Global variables        
  45. *
  46. **********************************************************************
  47. */
  48. struct FS__SMC_ATTRIBTYPE FS__SMC_cardattrib[FS_SMC_MAXUNIT];
  49. struct FS__SMC_PARAMTYPE  FS__SMC_cardparam[FS_SMC_MAXUNIT];
  50. /*********************************************************************
  51. *
  52. *             Local functions
  53. *
  54. **********************************************************************
  55. */
  56. /*********************************************************************
  57. *
  58. *             _FS_SMC_Set_SsfdcCmd
  59. */
  60. static void _FS_SMC_Set_SsfdcCmd(FS_u32 id,unsigned char cmd)
  61. {
  62.     FS_SMC_HW_X_SetCmd(id);
  63.     FS_SMC_HW_X_OutData(id,cmd);
  64.     FS_SMC_HW_X_SetData(id);
  65. }
  66. /*********************************************************************
  67. *
  68. *             _FS_SMC_Set_SsfdcAddr
  69. */
  70. static void _FS_SMC_Set_SsfdcAddr(FS_u32 id,unsigned char add)
  71. {
  72.     unsigned short addr;
  73.     addr=(unsigned short)FS__SMC_cardparam[id].Zone*FS__SMC_cardattrib[id].MaxBlocks+FS__SMC_cardparam[id].PhyBlock;
  74.     addr=addr*(unsigned short)FS__SMC_cardattrib[id].MaxSectors+FS__SMC_cardparam[id].Sector;
  75.     if((FS__SMC_cardattrib[id].Attribute &MPS)==PS256)       /* for 256byte/page */
  76.         addr=addr*2+(unsigned short)add;
  77. /*-----------------------------------------------*/
  78.     FS_SMC_HW_X_SetAddr(id);
  79.     FS_SMC_HW_X_OutData(id,0x00);
  80.     FS_SMC_HW_X_OutData(id,(unsigned char)addr);
  81.     FS_SMC_HW_X_OutData(id,(unsigned char)(addr/0x0100));
  82.     if((FS__SMC_cardattrib[id].Attribute &MADC)==AD4CYC)
  83.         FS_SMC_HW_X_OutData(id,(unsigned char)(FS__SMC_cardparam[id].Zone/2)); /* Patch */
  84.     FS_SMC_HW_X_SetData(id);
  85. }
  86. /*********************************************************************
  87. *
  88. *             _FS_SMC_Set_SsfdcBlock
  89. */
  90. static void _FS_SMC_Set_SsfdcBlock(FS_u32 id)
  91. {
  92.     unsigned short addr;
  93.     addr=(unsigned short)FS__SMC_cardparam[id].Zone*FS__SMC_cardattrib[id].MaxBlocks+FS__SMC_cardparam[id].PhyBlock;
  94.     addr=addr*(unsigned short)FS__SMC_cardattrib[id].MaxSectors;
  95.     if((FS__SMC_cardattrib[id].Attribute &MPS)==PS256)       /* for 256byte/page */
  96.         addr=addr*2;
  97. /*-----------------------------------------------*/
  98.     FS_SMC_HW_X_SetAddr(id);
  99.     FS_SMC_HW_X_OutData(id,(unsigned char)addr);
  100.     FS_SMC_HW_X_OutData(id,(unsigned char)(addr/0x0100));
  101.     if((FS__SMC_cardattrib[id].Attribute &MADC)==AD4CYC)
  102.         FS_SMC_HW_X_OutData(id,(unsigned char)(FS__SMC_cardparam[id].Zone/2)); /* Patch */
  103.     FS_SMC_HW_X_SetData(id);
  104. }
  105. /*********************************************************************
  106. *
  107. *             _FS_SMC_Set_SsfdcChip
  108. */
  109. static void _FS_SMC_Set_SsfdcChip(FS_u32 id)
  110. {
  111.     FS_SMC_HW_X_SetAddr(id);
  112.     FS_SMC_HW_X_OutData(id,0x00);
  113.     FS_SMC_HW_X_SetData(id);
  114. }
  115. /*********************************************************************
  116. *
  117. *             _FS_SMC_Set_SsfdcStandby
  118. */
  119. static void _FS_SMC_Set_SsfdcStandby(FS_u32 id)
  120. {
  121.     FS_SMC_HW_X_SetStandby(id);
  122. }
  123. /*********************************************************************
  124. *
  125. *             _FS_SMC_Chk_SsfdcBusy
  126. */
  127. static int _FS_SMC_Chk_SsfdcBusy(FS_u32 id,unsigned short time)
  128. {
  129.     FS_SMC_HW_X_SetTimer(id,time);
  130.     while(FS_SMC_HW_X_ChkTimer(id))
  131.         if(! FS_SMC_HW_X_ChkBusy(id)) {
  132.             FS_SMC_HW_X_StopTimer(id);
  133.             return(SUCCESS);
  134.         }
  135.     FS_SMC_HW_X_StopTimer(id);
  136.     return(ERROR);
  137. }
  138. /*********************************************************************
  139. *
  140. *             _FS_SMC_Chk_SsfdcStatus
  141. */
  142. static int _FS_SMC_Chk_SsfdcStatus(FS_u32 id)
  143. {
  144.     if(FS_SMC_HW_X_InData(id) &WR_FAIL)   return(ERROR);
  145.     return(SUCCESS);
  146. }
  147. /*********************************************************************
  148. *
  149. *             _FS_SMC_Reset_SsfdcErr
  150. */
  151. static void _FS_SMC_Reset_SsfdcErr(FS_u32 id)
  152. {
  153.     FS_SMC_HW_X_SetCmd(id);
  154.     FS_SMC_HW_X_OutData(id,RST_CHIP);
  155.     FS_SMC_HW_X_SetData(id);
  156.     FS_SMC_HW_X_SetTimer(id,BUSY_RESET);
  157.     while(FS_SMC_HW_X_ChkTimer(id))
  158.         if(! FS_SMC_HW_X_ChkBusy(id))     break;
  159.     FS_SMC_HW_X_StopTimer(id);
  160.     FS_SMC_HW_X_SetStandby(id);
  161. }
  162. /*********************************************************************
  163. *
  164. *             _FS_SMC_Read_SsfdcBuf
  165. */
  166. static void _FS_SMC_Read_SsfdcBuf(FS_u32 id,unsigned char *databuf,unsigned char *redundant)
  167. {
  168.     int i;
  169.     for(i=0x00;i<(((FS__SMC_cardattrib[id].Attribute &MPS)==PS256)?0x100:0x200);i++)
  170.         *databuf++   =FS_SMC_HW_X_InData(id);
  171.     for(i=0x00;i<(((FS__SMC_cardattrib[id].Attribute &MPS)==PS256)?0x08:0x10);i++)
  172.         *redundant++ =FS_SMC_HW_X_InData(id);
  173. }
  174. /*********************************************************************
  175. *
  176. *             _FS_SMC_Write_SsfdcBuf
  177. */
  178. static void _FS_SMC_Write_SsfdcBuf(FS_u32 id,unsigned char *databuf,unsigned char *redundant)
  179. {
  180.     int i;
  181.     for(i=0x00;i<(((FS__SMC_cardattrib[id].Attribute &MPS)==PS256)?0x100:0x200);i++)
  182.         FS_SMC_HW_X_OutData(id,*databuf++);
  183.     for(i=0x00;i<(((FS__SMC_cardattrib[id].Attribute &MPS)==PS256)?0x08:0x10);i++)
  184.         FS_SMC_HW_X_OutData(id,*redundant++);
  185. }
  186. /*********************************************************************
  187. *
  188. *             _FS_SMC_Read_SsfdcWord
  189. */
  190. static void _FS_SMC_Read_SsfdcWord(FS_u32 id,unsigned short *pdata)
  191. {
  192.     *pdata =FS_SMC_HW_X_InData(id)*0x100;
  193.     *pdata|=(unsigned char)FS_SMC_HW_X_InData(id);
  194. }
  195. /*********************************************************************
  196. *
  197. *             _FS_SMC_ReadRedt_SsfdcBuf
  198. */
  199. static void _FS_SMC_ReadRedt_SsfdcBuf(FS_u32 id,unsigned char *redundant)
  200. {
  201.     char i;
  202.     for(i=0x00;i<(((FS__SMC_cardattrib[id].Attribute &MPS)==PS256)?0x08:0x10);i++)
  203.         redundant[i] =FS_SMC_HW_X_InData(id);
  204. }
  205. /*********************************************************************
  206. *
  207. *             _FS_SMC_WriteRedt_SsfdcBuf
  208. */
  209. static void _FS_SMC_WriteRedt_SsfdcBuf(FS_u32 id,unsigned char *redundant)
  210. {
  211.     char i;
  212.     for(i=0x00;i<(((FS__SMC_cardattrib[id].Attribute &MPS)==PS256)?0x08:0x10);i++)
  213.         FS_SMC_HW_X_OutData(id,*redundant++);
  214. }
  215. /*********************************************************************
  216. *
  217. *             _FS_SMC_Check_DevCode
  218. */
  219. static unsigned char _FS_SMC_Check_DevCode(unsigned char dcode)
  220. {
  221.     switch(dcode){
  222.         case 0x6E:
  223.         case 0xE8:
  224.         case 0xEC:  return(SSFDC1MB);       /*  8Mbit (1M) NAND */
  225.         case 0x64:
  226.         case 0xEA:  return(SSFDC2MB);       /* 16Mbit (2M) NAND */
  227.         case 0x6B:
  228.         case 0xE3:
  229.         case 0xE5:  return(SSFDC4MB);       /* 32Mbit (4M) NAND */
  230.         case 0xE6:  return(SSFDC8MB);       /* 64Mbit (8M) NAND */
  231.         case 0x73:  return(SSFDC16MB);      /*128Mbit (16M)NAND */
  232.         case 0x75:  return(SSFDC32MB);      /*256Mbit (32M)NAND */
  233.         case 0x76:  return(SSFDC64MB);      /*512Mbit (64M)NAND */
  234.         case 0x79:  return(SSFDC128MB);     /*  1Gbit(128M)NAND */
  235.         default:    return(0xff);
  236.     }
  237. }
  238. /*********************************************************************
  239. *
  240. *             Global functions
  241. *
  242. **********************************************************************
  243. */
  244. /*********************************************************************
  245. *
  246. *             FS__SMC_PHY_Reset
  247. */
  248. void FS__SMC_PHY_Reset(FS_u32 id)
  249. {
  250.     _FS_SMC_Set_SsfdcCmd(id,RST_CHIP);
  251. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  252.     _FS_SMC_Chk_SsfdcBusy(id,BUSY_RESET);
  253. #else
  254.     FS_SMC_HW_X_WaitTimer(id,BUSY_RESET);
  255. #endif
  256.     _FS_SMC_Set_SsfdcCmd(id,READ);
  257. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  258.     _FS_SMC_Chk_SsfdcBusy(id,BUSY_READ);
  259. #else
  260.     FS_SMC_HW_X_WaitTimer(id,BUSY_READ);
  261. #endif
  262.     _FS_SMC_Set_SsfdcStandby(id);
  263. }
  264. /*********************************************************************
  265. *
  266. *             FS__SMC_PHY_WriteRedtMode
  267. */
  268. void FS__SMC_PHY_WriteRedtMode(FS_u32 id)
  269. {
  270.     _FS_SMC_Set_SsfdcCmd(id,RST_CHIP);
  271. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  272.     _FS_SMC_Chk_SsfdcBusy(id,BUSY_RESET);
  273. #else
  274.     FS_SMC_HW_X_WaitTimer(id,BUSY_RESET);
  275. #endif
  276.     _FS_SMC_Set_SsfdcCmd(id,READ_REDT);
  277. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  278.     _FS_SMC_Chk_SsfdcBusy(id,BUSY_READ);
  279. #else
  280.     FS_SMC_HW_X_WaitTimer(id,BUSY_READ);
  281. #endif
  282.     _FS_SMC_Set_SsfdcStandby(id);
  283. }
  284. /*********************************************************************
  285. *
  286. *             FS__SMC_PHY_ReadID
  287. */
  288. void FS__SMC_PHY_ReadID(FS_u32 id,unsigned short *pid)
  289. {
  290.     _FS_SMC_Set_SsfdcCmd(id,READ_ID);
  291.     _FS_SMC_Set_SsfdcChip(id);
  292.     _FS_SMC_Read_SsfdcWord(id,pid);
  293.     _FS_SMC_Set_SsfdcStandby(id);
  294. }
  295. /*********************************************************************
  296. *
  297. *             FS__SMC_PHY_ReadSect
  298. */
  299. int FS__SMC_PHY_ReadSect(FS_u32 id,unsigned char *buf,unsigned char *redundant)
  300. {
  301.     _FS_SMC_Set_SsfdcCmd(id,READ);
  302.     _FS_SMC_Set_SsfdcAddr(id,EVEN);
  303. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  304.     if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_READ))
  305.         { _FS_SMC_Reset_SsfdcErr(id);        return(ERROR); }
  306. #else
  307.     FS_SMC_HW_X_WaitTimer(id,BUSY_READ);
  308. #endif
  309.     _FS_SMC_Read_SsfdcBuf(id,buf,redundant);
  310. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  311.     if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_READ))
  312.         { _FS_SMC_Reset_SsfdcErr(id);        return(ERROR); }
  313. #else
  314.     FS_SMC_HW_X_WaitTimer(id,BUSY_READ);
  315. #endif
  316.     if((FS__SMC_cardattrib[id].Attribute &MPS)==PS256) {
  317.         _FS_SMC_Set_SsfdcCmd(id,READ);
  318.         _FS_SMC_Set_SsfdcAddr(id,ODD);
  319. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  320.         if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_READ))
  321.             { _FS_SMC_Reset_SsfdcErr(id);    return(ERROR); }
  322. #else
  323.         FS_SMC_HW_X_WaitTimer(id,BUSY_READ);
  324. #endif
  325.         _FS_SMC_Read_SsfdcBuf(id,buf+0x100,redundant+0x08);
  326. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  327.         if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_READ))
  328.             { _FS_SMC_Reset_SsfdcErr(id);    return(ERROR); }
  329. #else
  330.         FS_SMC_HW_X_WaitTimer(id,BUSY_READ);
  331. #endif
  332.     }
  333.     _FS_SMC_Set_SsfdcStandby(id);
  334.     return(SUCCESS);
  335. }
  336. /*********************************************************************
  337. *
  338. *             FS__SMC_PHY_WriteSect
  339. */
  340. int FS__SMC_PHY_WriteSect(FS_u32 id,unsigned char *buf,unsigned char *redundant)
  341. {
  342.     _FS_SMC_Set_SsfdcCmd(id,WRDATA);
  343.     _FS_SMC_Set_SsfdcAddr(id,EVEN);
  344.     _FS_SMC_Write_SsfdcBuf(id,buf,redundant);
  345.     _FS_SMC_Set_SsfdcCmd(id,WRITE);
  346.     if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_PROG))   
  347.         { _FS_SMC_Reset_SsfdcErr(id);        return(ERROR); }
  348.     if((FS__SMC_cardattrib[id].Attribute &MPS)==PS256) {
  349.         _FS_SMC_Set_SsfdcCmd(id,RDSTATUS);
  350.         if(_FS_SMC_Chk_SsfdcStatus(id))    
  351.             { _FS_SMC_Set_SsfdcStandby(id);  return(SUCCESS); }
  352.         _FS_SMC_Set_SsfdcCmd(id,WRDATA);
  353.         _FS_SMC_Set_SsfdcAddr(id,ODD);
  354.         _FS_SMC_Write_SsfdcBuf(id,buf+0x100,redundant+0x08);
  355.         _FS_SMC_Set_SsfdcCmd(id,WRITE);
  356.         if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_PROG)) 
  357.             { _FS_SMC_Reset_SsfdcErr(id);    return(ERROR); }
  358.     }
  359.     _FS_SMC_Set_SsfdcStandby(id);
  360.     return(SUCCESS);
  361. }
  362. /*********************************************************************
  363. *
  364. *             FS__SMC_PHY_EraseBlock
  365. */
  366. int FS__SMC_PHY_EraseBlock(FS_u32 id)
  367. {
  368.     _FS_SMC_Set_SsfdcCmd(id,ERASE1);
  369.     _FS_SMC_Set_SsfdcBlock(id);
  370.     _FS_SMC_Set_SsfdcCmd(id,ERASE2);
  371.     if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_ERASE))  
  372.         { _FS_SMC_Reset_SsfdcErr(id);        return(ERROR); }
  373.     _FS_SMC_Set_SsfdcStandby(id);
  374.     return(SUCCESS);
  375. }
  376. /*********************************************************************
  377. *
  378. *             FS__SMC_PHY_ReadRedtData
  379. */
  380. int FS__SMC_PHY_ReadRedtData(FS_u32 id,unsigned char *redundant)
  381. {
  382.     _FS_SMC_Set_SsfdcCmd(id,READ_REDT);
  383.     _FS_SMC_Set_SsfdcAddr(id,EVEN);
  384. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  385.     if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_READ))
  386.         { _FS_SMC_Reset_SsfdcErr(id);        return(ERROR); }
  387. #else
  388.     FS_SMC_HW_X_WaitTimer(id,BUSY_READ);
  389. #endif
  390.     _FS_SMC_ReadRedt_SsfdcBuf(id,redundant);
  391. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  392.     if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_READ))
  393.         { _FS_SMC_Reset_SsfdcErr(id);        return(ERROR); }
  394. #else
  395.     FS_SMC_HW_X_WaitTimer(id,BUSY_READ);
  396. #endif
  397.     if((FS__SMC_cardattrib[id].Attribute &MPS)==PS256) {
  398.         _FS_SMC_Set_SsfdcCmd(id,READ_REDT);
  399.         _FS_SMC_Set_SsfdcAddr(id,ODD);
  400. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  401.         if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_READ))
  402.             { _FS_SMC_Reset_SsfdcErr(id);    return(ERROR); }
  403. #else
  404.         FS_SMC_HW_X_WaitTimer(id,BUSY_READ);
  405. #endif
  406.         _FS_SMC_ReadRedt_SsfdcBuf(id,redundant+0x08);
  407. #if FS_SMC_HW_SUPPORT_BSYLINE_CHECK
  408.         if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_READ))
  409.             { _FS_SMC_Reset_SsfdcErr(id);    return(ERROR); }
  410. #else
  411.         FS_SMC_HW_X_WaitTimer(id,BUSY_READ);
  412. #endif
  413.     }
  414.     _FS_SMC_Set_SsfdcStandby(id);
  415.     return(SUCCESS);
  416. }
  417. /*********************************************************************
  418. *
  419. *             FS__SMC_PHY_WriteRedtData
  420. */
  421. int FS__SMC_PHY_WriteRedtData(FS_u32 id,unsigned char *redundant)
  422. {
  423.     _FS_SMC_Set_SsfdcCmd(id,WRDATA);
  424.     _FS_SMC_Set_SsfdcAddr(id,EVEN);
  425.     _FS_SMC_WriteRedt_SsfdcBuf(id,redundant);
  426.     _FS_SMC_Set_SsfdcCmd(id,WRITE);
  427.     if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_PROG))     
  428.         { _FS_SMC_Reset_SsfdcErr(id);        return(ERROR); }
  429.     if((FS__SMC_cardattrib[id].Attribute &MPS)==PS256) {
  430.         _FS_SMC_Set_SsfdcCmd(id,RDSTATUS);
  431.         if(_FS_SMC_Chk_SsfdcStatus(id))        
  432.             { _FS_SMC_Set_SsfdcStandby(id);  return(SUCCESS); }
  433.         _FS_SMC_Set_SsfdcCmd(id,WRDATA);
  434.         _FS_SMC_Set_SsfdcAddr(id,ODD);
  435.         _FS_SMC_WriteRedt_SsfdcBuf(id,redundant+0x08);
  436.         _FS_SMC_Set_SsfdcCmd(id,WRITE);
  437.         if(_FS_SMC_Chk_SsfdcBusy(id,BUSY_PROG))   
  438.             { _FS_SMC_Reset_SsfdcErr(id);    return(ERROR); }
  439.     }
  440.     _FS_SMC_Set_SsfdcStandby(id);
  441.     return(SUCCESS);
  442. }
  443. /*********************************************************************
  444. *
  445. *             FS__SMC_PHY_CheckStatus
  446. */
  447. int FS__SMC_PHY_CheckStatus(FS_u32 id)
  448. {
  449.     _FS_SMC_Set_SsfdcCmd(id,RDSTATUS);
  450.     if(_FS_SMC_Chk_SsfdcStatus(id))
  451.         { _FS_SMC_Set_SsfdcStandby(id);      return(ERROR); }
  452.     _FS_SMC_Set_SsfdcStandby(id);
  453.     return(SUCCESS);
  454. }
  455. /*********************************************************************
  456. *
  457. *             FS__SMC_PHY_Set_Model
  458. */
  459. int FS__SMC_PHY_Set_Model(FS_u32 id,unsigned char dcode)
  460. {
  461.     switch(_FS_SMC_Check_DevCode(dcode))   {
  462.         case SSFDC1MB:
  463.             FS__SMC_cardattrib[id].Model        = SSFDC1MB;
  464.             FS__SMC_cardattrib[id].Attribute    = FLASH | AD3CYC | BS16 | PS256;
  465.             FS__SMC_cardattrib[id].MaxZones     = 1;
  466.             FS__SMC_cardattrib[id].MaxBlocks    = 256;
  467.             FS__SMC_cardattrib[id].MaxLogBlocks = 250;
  468.             FS__SMC_cardattrib[id].MaxSectors   = 8;
  469.             break;
  470.         case SSFDC2MB:
  471.             FS__SMC_cardattrib[id].Model        = SSFDC2MB;
  472.             FS__SMC_cardattrib[id].Attribute    = FLASH | AD3CYC | BS16 | PS256;
  473.             FS__SMC_cardattrib[id].MaxZones     = 1;
  474.             FS__SMC_cardattrib[id].MaxBlocks    = 512;
  475.             FS__SMC_cardattrib[id].MaxLogBlocks = 500;
  476.             FS__SMC_cardattrib[id].MaxSectors   = 8;
  477.             break;
  478.         case SSFDC4MB:
  479.             FS__SMC_cardattrib[id].Model        = SSFDC4MB;
  480.             FS__SMC_cardattrib[id].Attribute    = FLASH | AD3CYC | BS16 | PS512;
  481.             FS__SMC_cardattrib[id].MaxZones     = 1;
  482.             FS__SMC_cardattrib[id].MaxBlocks    = 512;
  483.             FS__SMC_cardattrib[id].MaxLogBlocks = 500;
  484.             FS__SMC_cardattrib[id].MaxSectors   = 16;
  485.             break;
  486.         case SSFDC8MB:
  487.             FS__SMC_cardattrib[id].Model        = SSFDC8MB;
  488.             FS__SMC_cardattrib[id].Attribute    = FLASH | AD3CYC | BS16 | PS512;
  489.             FS__SMC_cardattrib[id].MaxZones     = 1;
  490.             FS__SMC_cardattrib[id].MaxBlocks    = 1024;
  491.             FS__SMC_cardattrib[id].MaxLogBlocks = 1000;
  492.             FS__SMC_cardattrib[id].MaxSectors   = 16;
  493.             break;
  494.         case SSFDC16MB:
  495.             FS__SMC_cardattrib[id].Model        = SSFDC16MB;
  496.             FS__SMC_cardattrib[id].Attribute    = FLASH | AD3CYC | BS32 | PS512;
  497.             FS__SMC_cardattrib[id].MaxZones     = 1;
  498.             FS__SMC_cardattrib[id].MaxBlocks    = 1024;
  499.             FS__SMC_cardattrib[id].MaxLogBlocks = 1000;
  500.             FS__SMC_cardattrib[id].MaxSectors   = 32;
  501.             break;
  502.         case SSFDC32MB:
  503.             FS__SMC_cardattrib[id].Model        = SSFDC32MB;
  504.             FS__SMC_cardattrib[id].Attribute    = FLASH | AD3CYC | BS32 | PS512;
  505.             FS__SMC_cardattrib[id].MaxZones     = 2;
  506.             FS__SMC_cardattrib[id].MaxBlocks    = 1024;
  507.             FS__SMC_cardattrib[id].MaxLogBlocks = 1000;
  508.             FS__SMC_cardattrib[id].MaxSectors   = 32;
  509.             break;
  510.         case SSFDC64MB:
  511.             FS__SMC_cardattrib[id].Model        = SSFDC64MB;
  512.             FS__SMC_cardattrib[id].Attribute    = FLASH | AD4CYC | BS32 | PS512;
  513.             FS__SMC_cardattrib[id].MaxZones     = 4;
  514.             FS__SMC_cardattrib[id].MaxBlocks    = 1024;
  515.             FS__SMC_cardattrib[id].MaxLogBlocks = 1000;
  516.             FS__SMC_cardattrib[id].MaxSectors   = 32;
  517.             break;
  518.         case SSFDC128MB:
  519.             FS__SMC_cardattrib[id].Model        = SSFDC128MB;
  520.             FS__SMC_cardattrib[id].Attribute    = FLASH | AD4CYC | BS32 | PS512;
  521.             FS__SMC_cardattrib[id].MaxZones     = 8;
  522.             FS__SMC_cardattrib[id].MaxBlocks    = 1024;
  523.             FS__SMC_cardattrib[id].MaxLogBlocks = 1000;
  524.             FS__SMC_cardattrib[id].MaxSectors   = 32;
  525.             break;
  526.     default:
  527.             FS__SMC_cardattrib[id].Model        = NOSSFDC;
  528.             return(ERROR);
  529.     }
  530.     return(SUCCESS);
  531. }
  532. /*********************************************************************
  533. *
  534. *             FS__SMC_PHY_Cnt_Reset
  535. */
  536. void FS__SMC_PHY_Cnt_Reset(FS_u32 id)
  537. {
  538.     FS_SMC_HW_X_SetStandby(id);
  539.     FS_SMC_HW_X_VccOff(id);
  540. }
  541. /*********************************************************************
  542. *
  543. *             FS__SMC_PHY_Cnt_PowerOn
  544. */
  545. int FS__SMC_PHY_Cnt_PowerOn(FS_u32 id)
  546. {
  547.     FS_SMC_HW_X_VccOn(id);
  548.     FS_SMC_HW_X_WaitTimer(id,TIME_PON);
  549.     if(FS_SMC_HW_X_ChkPower(id))
  550.         return(SUCCESS);
  551.     FS_SMC_HW_X_VccOff(id);
  552.     return(ERROR);
  553. }
  554. /*********************************************************************
  555. *
  556. *             FS__SMC_PHY_Chk_CntPower
  557. */
  558. int FS__SMC_PHY_Chk_CntPower(FS_u32 id)
  559. {
  560.     if(FS_SMC_HW_X_ChkPower(id))
  561.         return(SUCCESS);    /* Power On */
  562.     return(ERROR);          /* Power Off */
  563. }
  564. /*********************************************************************
  565. *
  566. *             FS__SMC_PHY_Chk_CardExist
  567. */
  568. int FS__SMC_PHY_Chk_CardExist(FS_u32 id)
  569. {
  570.     char i,j,k;
  571.     if(! FS_SMC_HW_X_ChkStatus(id))                   /***** Not Status Change *****/
  572.         if(FS_SMC_HW_X_ChkCardIn(id)) return(SUCCESS);    /* Card exist in Slot */
  573.     for(i=0,j=0,k=0; i<0x10; i++) {
  574.         if(FS_SMC_HW_X_ChkCardIn(id))                 /***** Status Change *****/
  575.              { j++; k=0; }
  576.         else { j=0; k++; }
  577.         if(j>3)     return(SUCCESS);            /* Card exist in Slot */
  578.         if(k>3)     return(ERROR);              /* NO Card exist in Slot */
  579.         FS_SMC_HW_X_WaitTimer(id,TIME_CDCHK);
  580.     }
  581.     return(ERROR);
  582. }
  583. /*********************************************************************
  584. *
  585. *             FS__SMC_PHY_Chk_CardStsChg
  586. */
  587. int FS__SMC_PHY_Chk_CardStsChg(FS_u32 id)
  588. {
  589.     if(FS_SMC_HW_X_ChkStatus(id))
  590.         return(ERROR);      /* Status Change */
  591.     return(SUCCESS);        /* Not Status Change */
  592. }
  593. /*********************************************************************
  594. *
  595. *             FS__SMC_PHY_Chk_WP
  596. */
  597. int FS__SMC_PHY_Chk_WP(FS_u32 id)
  598. {   /* ERROR: WP, SUCCESS: Not WP */
  599.     char i;
  600.     for(i=0; i<0x08; i++) {
  601.         if(FS_SMC_HW_X_ChkWP(id))
  602.             return(ERROR);
  603.         FS_SMC_HW_X_WaitTimer(id,TIME_WPCHK);
  604.     }
  605.     return(SUCCESS);
  606. }
  607. #endif /* FS_USE_SMC_DRIVER */