亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 948 | 回復(fù): 0
打印 上一主題 下一主題

移植nand支持到uboot, 使用nand_legacy.c [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2011-12-23 03:25 |只看該作者 |倒序瀏覽

網(wǎng)上大部分是利用drivers/nand/nand.c或者common/env_nand.c的,但是還有個drivers/nand_legacy/nand_legacy.c,我還不清楚為什么會有2個目錄,據(jù)說新的uboot是靠nand_legacy.c實現(xiàn)的,于是我想移植到nand_legacy.c下。

 

1、先make smdk2410_config,make成功后再拷貝如下代碼到nand_legacy.c的適當(dāng)位置:

  1. /*-----------------------------------------------------------------------

  2. * NAND flash basic functions

  3. * Added by liuyaojin 2009.5.20

  4. * Copied from board/mpl/vcma9/vcma9.h & vcma9.c

  5. */
  6. #if (CONFIG_SMDK2410)
  7. #include <s3c2410.h>


  8. typedef enum {

  9. NFCE_LOW,

  10. NFCE_HIGH

  11. } NFCE_STATE;
  12. static inline void NF_Conf(u16 conf)

  13. {

  14. S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
  15. nand->NFCONF = conf;

  16. }
  17. static inline void NF_Cmd(u8 cmd)

  18. {

  19. S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
  20. nand->NFCMD = cmd;

  21. }
  22. static inline void NF_CmdW(u8 cmd)

  23. {

  24. NF_Cmd(cmd);

  25. udelay(1);

  26. }
  27. static inline void NF_Addr(u8 addr)

  28. {

  29. S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
  30. nand->NFADDR = addr;

  31. }
  32. static inline void NF_SetCE(NFCE_STATE s)

  33. {

  34. S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
  35. switch (s) {

  36. case NFCE_LOW:

  37. nand->NFCONF &= ~(1<<11);

  38. break;
  39. case NFCE_HIGH:

  40. nand->NFCONF |= (1<<11);

  41. break;

  42. }

  43. }
  44. static inline void NF_WaitRB(void)

  45. {

  46. S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
  47. while (!(nand->NFSTAT & (1<<0)));

  48. }
  49. static inline void NF_Write(u8 data)

  50. {

  51. S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
  52. nand->NFDATA = data;

  53. }
  54. static inline u8 NF_Read(void)

  55. {

  56. S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
  57. return(nand->NFDATA);

  58. }
  59. static inline void NF_Init_ECC(void)

  60. {

  61. S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
  62. nand->NFCONF |= (1<<12);

  63. }
  64. static inline u32 NF_Read_ECC(void)

  65. {

  66. S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
  67. return(nand->NFECC);

  68. }
  69. extern ulong nand_probe(ulong physadr);
  70. static inline void NF_Reset(void)

  71. {

  72. int i;
  73. NF_SetCE(NFCE_LOW);

  74. NF_Cmd(0xFF); /* reset command */

  75. for(i = 0; i < 10; i++); /* tWB = 100ns. */

  76. NF_WaitRB(); /* wait 200~500us; */

  77. NF_SetCE(NFCE_HIGH);

  78. }
  79. static inline void NF_Init(void)

  80. {

  81. #if 0 /* a little bit too optimistic */

  82. #define TACLS 0

  83. #define TWRPH0 3

  84. #define TWRPH1 0

  85. #else

  86. #define TACLS 0

  87. #define TWRPH0 4

  88. #define TWRPH1 2

  89. #endif
  90. NF_Conf((1<<15)|(0<<14)|(0<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0));

  91. /*nand->NFCONF = (1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0); */

  92. /* 1 1 1 1, 1 xxx, r xxx, r xxx */

  93. /* En 512B 4step ECCR nFCE=H tACLS tWRPH0 tWRPH1 */
  94. NF_Reset();

  95. }
  96. void nand_init(void)

  97. {

  98. S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
  99. NF_Init();

  100. #ifdef DEBUG

  101. printf("NAND flash probing at 0x%.8lX/n", (ulong)nand);

  102. #endif

  103. printf ("%4lu MB/n", nand_probe((ulong)nand) >> 20);

  104. }
  105. #endif /* (CONFIG_SMDK2410) */



  106. 2、在nand_legacy.c頭上包含文件:

  107. #include <configs/smdk2410.h>

  108.  

  109. 3、在smdk2410.h把CFG_CMD_NAND打開,適當(dāng)位置中插入如下代碼:

  110.  

  111. //然后把下面這些宏定義放在smdk2410.h中
  112. /*-----------------------------------------------------------------------

  113. * NAND flash settings

  114. * Added by liuyaojin 2009.5.20

  115. * Copied from include/conifgs/vcma9.h

  116. */
  117. #define CFG_NAND_LEGACY
  118. //#if (CONFIG_COMMANDS & CFG_CMD_NAND)
  119. #define CFG_MAX_NAND_DEVICE 1 /* Max number of NAND devices */
  120. //nit i=0;
  121. #define SECTORSIZE 512
  122. #define ADDR_COLUMN 1

  123. #define ADDR_PAGE 2

  124. #define ADDR_COLUMN_PAGE 3
  125. #define NAND_ChipID_UNKNOWN 0x00

  126. #define NAND_MAX_FLOORS 1

  127. #define NAND_MAX_CHIPS 1
  128. #define NAND_WAIT_READY(nand) NF_WaitRB()
  129. #define NAND_DISABLE_CE(nand) NF_SetCE(NFCE_HIGH)

  130. #define NAND_ENABLE_CE(nand) NF_SetCE(NFCE_LOW)


  131. #define WRITE_NAND_COMMAND(d, adr) NF_Cmd(d)

  132. #define WRITE_NAND_COMMANDW(d, adr) NF_CmdW(d)

  133. #define WRITE_NAND_ADDRESS(d, adr) NF_Addr(d)

  134. #define WRITE_NAND(d, adr) NF_Write(d)

  135. #define READ_NAND(adr) NF_Read()

  136. /* the following functions are NOP's because S3C24X0 handles this in hardware */

  137. #define NAND_CTL_CLRALE(nandptr)

  138. #define NAND_CTL_SETALE(nandptr)

  139. #define NAND_CTL_CLRCLE(nandptr)

  140. #define NAND_CTL_SETCLE(nandptr)
  141. /* #define CONFIG_MTD_NAND_VERIFY_WRITE 1 */
  142. /* This definition above is commented by Lu Xianzi. 2006.05.28

  143. Because there's no definition of a macro called __mem_pci,

  144. there will be a link error.

  145. */

  146. #define CONFIG_MTD_NAND_ECC_JFFS2 1
  147. //#endif /* CONFIG_COMMANDS & CFG_CMD_NAND */
  148. //---------------添加結(jié)束-----------------------

4、make即可

需要注意的地方:

1、必須定義 #define CFG_NAND_LEGACY

2、#if (CONFIG_COMMANDS & CFG_CMD_NAND) 好像不起作用,大家小心點

您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP