fsl_nfc.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. * TODO: Use same register defs for nand_spl mxc nand driver
  26. * and mtd mxc nand driver.
  27. *
  28. * Register map and bit definitions for the Freescale NAND Flash
  29. * Controller present in various i.MX devices.
  30. *
  31. * MX31 and MX27 have version 1 which has
  32. * 4 512 byte main buffers and
  33. * 4 16 byte spare buffers
  34. * to support up to 2K byte pagesize nand.
  35. * Reading or writing a 2K page requires 4 FDI/FDO cycles.
  36. *
  37. * MX25 has version 1.1 which has
  38. * 8 512 byte main buffers and
  39. * 8 64 byte spare buffers
  40. * to support up to 4K byte pagesize nand.
  41. * Reading or writing a 2K or 4K page requires only 1 FDI/FDO cycle.
  42. * Also some of registers are moved and/or changed meaning as seen below.
  43. */
  44. #if defined(CONFIG_MX31) || defined(CONFIG_MX27)
  45. #define MXC_NFC_V1
  46. #elif defined(CONFIG_MX25)
  47. #define MXC_NFC_V1_1
  48. #else
  49. #warning "MXC NFC version not defined"
  50. #endif
  51. #if defined(MXC_NFC_V1)
  52. #define NAND_MXC_NR_BUFS 4
  53. #define NAND_MXC_SPARE_BUF_SIZE 16
  54. #define NAND_MXC_REG_OFFSET 0xe00
  55. #define NAND_MXC_2K_MULTI_CYCLE 1
  56. #elif defined(MXC_NFC_V1_1)
  57. #define NAND_MXC_NR_BUFS 8
  58. #define NAND_MXC_SPARE_BUF_SIZE 64
  59. #define NAND_MXC_REG_OFFSET 0x1e00
  60. #else
  61. #error "define CONFIG_NAND_MXC_VXXX to use the mxc spl_nand driver"
  62. #endif
  63. struct fsl_nfc_regs {
  64. u32 main_area[NAND_MXC_NR_BUFS][512/4];
  65. u32 spare_area[NAND_MXC_NR_BUFS][NAND_MXC_SPARE_BUF_SIZE/4];
  66. /*
  67. * reserved size is offset of nfc registers
  68. * minus total main and spare sizes
  69. */
  70. u8 reserved1[NAND_MXC_REG_OFFSET
  71. - NAND_MXC_NR_BUFS * (512 + NAND_MXC_SPARE_BUF_SIZE)];
  72. #if defined(MXC_NFC_V1)
  73. u16 bufsiz;
  74. u16 reserved2;
  75. u16 buffer_address;
  76. u16 flash_add;
  77. u16 flash_cmd;
  78. u16 configuration;
  79. u16 ecc_status_result;
  80. u16 ecc_rslt_main_area;
  81. u16 ecc_rslt_spare_area;
  82. u16 nf_wr_prot;
  83. u16 unlock_start_blk_add;
  84. u16 unlock_end_blk_add;
  85. u16 nand_flash_wr_pr_st;
  86. u16 nand_flash_config1;
  87. u16 nand_flash_config2;
  88. #elif defined(MXC_NFC_V1_1)
  89. u16 reserved2[2];
  90. u16 buffer_address;
  91. u16 flash_add;
  92. u16 flash_cmd;
  93. u16 configuration;
  94. u16 ecc_status_result;
  95. u16 ecc_status_result2;
  96. u16 spare_area_size;
  97. u16 nf_wr_prot;
  98. u16 reserved3[2];
  99. u16 nand_flash_wr_pr_st;
  100. u16 nand_flash_config1;
  101. u16 nand_flash_config2;
  102. u16 reserved4;
  103. u16 unlock_start_blk_add0;
  104. u16 unlock_end_blk_add0;
  105. u16 unlock_start_blk_add1;
  106. u16 unlock_end_blk_add1;
  107. u16 unlock_start_blk_add2;
  108. u16 unlock_end_blk_add2;
  109. u16 unlock_start_blk_add3;
  110. u16 unlock_end_blk_add3;
  111. #endif
  112. };
  113. /*
  114. * Set INT to 0, FCMD to 1, rest to 0 in NFC_CONFIG2 Register for Command
  115. * operation
  116. */
  117. #define NFC_CMD 0x1
  118. /*
  119. * Set INT to 0, FADD to 1, rest to 0 in NFC_CONFIG2 Register for Address
  120. * operation
  121. */
  122. #define NFC_ADDR 0x2
  123. /*
  124. * Set INT to 0, FDI to 1, rest to 0 in NFC_CONFIG2 Register for Input
  125. * operation
  126. */
  127. #define NFC_INPUT 0x4
  128. /*
  129. * Set INT to 0, FDO to 001, rest to 0 in NFC_CONFIG2 Register for Data
  130. * Output operation
  131. */
  132. #define NFC_OUTPUT 0x8
  133. /*
  134. * Set INT to 0, FD0 to 010, rest to 0 in NFC_CONFIG2 Register for Read ID
  135. * operation
  136. */
  137. #define NFC_ID 0x10
  138. /*
  139. * Set INT to 0, FDO to 100, rest to 0 in NFC_CONFIG2 Register for Read
  140. * Status operation
  141. */
  142. #define NFC_STATUS 0x20
  143. /*
  144. * Set INT to 1, rest to 0 in NFC_CONFIG2 Register for Read Status
  145. * operation
  146. */
  147. #define NFC_INT 0x8000
  148. #ifdef MXC_NFC_V1_1
  149. #define NFC_4_8N_ECC (1 << 0)
  150. #endif
  151. #define NFC_SP_EN (1 << 2)
  152. #define NFC_ECC_EN (1 << 3)
  153. #define NFC_INT_MSK (1 << 4)
  154. #define NFC_BIG (1 << 5)
  155. #define NFC_RST (1 << 6)
  156. #define NFC_CE (1 << 7)
  157. #define NFC_ONE_CYCLE (1 << 8)
  158. #endif /* __FSL_NFC_H */