fsl_nfc.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * (c) 2009 Magnus Lilja <lilja.magnus@gmail.com>
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __FSL_NFC_H
  23. #define __FSL_NFC_H
  24. /*
  25. * Register map and bit definitions for the Freescale NAND Flash Controller
  26. * present in various i.MX devices.
  27. *
  28. * MX31 and MX27 have version 1, which has:
  29. * 4 512-byte main buffers and
  30. * 4 16-byte spare buffers
  31. * to support up to 2K byte pagesize nand.
  32. * Reading or writing a 2K page requires 4 FDI/FDO cycles.
  33. *
  34. * MX25 and MX35 have version 1.1, which has:
  35. * 8 512-byte main buffers and
  36. * 8 64-byte spare buffers
  37. * to support up to 4K byte pagesize nand.
  38. * Reading or writing a 2K or 4K page requires only 1 FDI/FDO cycle.
  39. * Also some of registers are moved and/or changed meaning as seen below.
  40. */
  41. #if defined(CONFIG_MX27) || defined(CONFIG_MX31)
  42. #define MXC_NFC_V1
  43. #define is_mxc_nfc_11() 0
  44. #elif defined(CONFIG_MX25) || defined(CONFIG_MX35)
  45. #define MXC_NFC_V1_1
  46. #define is_mxc_nfc_11() 1
  47. #else
  48. #error "MXC NFC implementation not supported"
  49. #endif
  50. #if defined(MXC_NFC_V1)
  51. #define NAND_MXC_NR_BUFS 4
  52. #define NAND_MXC_SPARE_BUF_SIZE 16
  53. #define NAND_MXC_REG_OFFSET 0xe00
  54. #define NAND_MXC_2K_MULTI_CYCLE
  55. #elif defined(MXC_NFC_V1_1)
  56. #define NAND_MXC_NR_BUFS 8
  57. #define NAND_MXC_SPARE_BUF_SIZE 64
  58. #define NAND_MXC_REG_OFFSET 0x1e00
  59. #endif
  60. struct fsl_nfc_regs {
  61. u8 main_area[NAND_MXC_NR_BUFS][0x200];
  62. u8 spare_area[NAND_MXC_NR_BUFS][NAND_MXC_SPARE_BUF_SIZE];
  63. /*
  64. * reserved size is offset of nfc registers
  65. * minus total main and spare sizes
  66. */
  67. u8 reserved1[NAND_MXC_REG_OFFSET
  68. - NAND_MXC_NR_BUFS * (512 + NAND_MXC_SPARE_BUF_SIZE)];
  69. #if defined(MXC_NFC_V1)
  70. u16 buf_size;
  71. u16 reserved2;
  72. u16 buf_addr;
  73. u16 flash_addr;
  74. u16 flash_cmd;
  75. u16 config;
  76. u16 ecc_status_result;
  77. u16 rsltmain_area;
  78. u16 rsltspare_area;
  79. u16 wrprot;
  80. u16 unlockstart_blkaddr;
  81. u16 unlockend_blkaddr;
  82. u16 nf_wrprst;
  83. u16 config1;
  84. u16 config2;
  85. #elif defined(MXC_NFC_V1_1)
  86. u16 reserved2[2];
  87. u16 buf_addr;
  88. u16 flash_addr;
  89. u16 flash_cmd;
  90. u16 config;
  91. u32 ecc_status_result;
  92. u16 spare_area_size;
  93. u16 wrprot;
  94. u16 reserved3[2];
  95. u16 nf_wrprst;
  96. u16 config1;
  97. u16 config2;
  98. u16 reserved4;
  99. u16 unlockstart_blkaddr;
  100. u16 unlockend_blkaddr;
  101. u16 unlockstart_blkaddr1;
  102. u16 unlockend_blkaddr1;
  103. u16 unlockstart_blkaddr2;
  104. u16 unlockend_blkaddr2;
  105. u16 unlockstart_blkaddr3;
  106. u16 unlockend_blkaddr3;
  107. #endif
  108. };
  109. /*
  110. * Set INT to 0, FCMD to 1, rest to 0 in NFC_CONFIG2 Register for Command
  111. * operation
  112. */
  113. #define NFC_CMD 0x1
  114. /*
  115. * Set INT to 0, FADD to 1, rest to 0 in NFC_CONFIG2 Register for Address
  116. * operation
  117. */
  118. #define NFC_ADDR 0x2
  119. /*
  120. * Set INT to 0, FDI to 1, rest to 0 in NFC_CONFIG2 Register for Input
  121. * operation
  122. */
  123. #define NFC_INPUT 0x4
  124. /*
  125. * Set INT to 0, FDO to 001, rest to 0 in NFC_CONFIG2 Register for Data
  126. * Output operation
  127. */
  128. #define NFC_OUTPUT 0x8
  129. /*
  130. * Set INT to 0, FD0 to 010, rest to 0 in NFC_CONFIG2 Register for Read ID
  131. * operation
  132. */
  133. #define NFC_ID 0x10
  134. /*
  135. * Set INT to 0, FDO to 100, rest to 0 in NFC_CONFIG2 Register for Read
  136. * Status operation
  137. */
  138. #define NFC_STATUS 0x20
  139. /*
  140. * Set INT to 1, rest to 0 in NFC_CONFIG2 Register for Read Status
  141. * operation
  142. */
  143. #define NFC_INT 0x8000
  144. #ifdef MXC_NFC_V1_1
  145. #define NFC_4_8N_ECC (1 << 0)
  146. #endif
  147. #define NFC_SP_EN (1 << 2)
  148. #define NFC_ECC_EN (1 << 3)
  149. #define NFC_INT_MSK (1 << 4)
  150. #define NFC_BIG (1 << 5)
  151. #define NFC_RST (1 << 6)
  152. #define NFC_CE (1 << 7)
  153. #define NFC_ONE_CYCLE (1 << 8)
  154. #define NFC_FP_INT (1 << 11)
  155. #endif /* __FSL_NFC_H */