nand_defs.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
  3. *
  4. * Parts shamelesly stolen from Linux Kernel source tree.
  5. *
  6. * ------------------------------------------------------------
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #ifndef _NAND_DEFS_H_
  27. #define _NAND_DEFS_H_
  28. #include <asm/arch/hardware.h>
  29. #define MASK_CLE 0x10
  30. #define MASK_ALE 0x0a
  31. #define NAND_CE0CLE ((volatile u_int8_t *)(CFG_NAND_BASE + 0x10))
  32. #define NAND_CE0ALE ((volatile u_int8_t *)(CFG_NAND_BASE + 0x0a))
  33. #define NAND_CE0DATA ((volatile u_int8_t *)CFG_NAND_BASE)
  34. typedef struct {
  35. u_int32_t NRCSR;
  36. u_int32_t AWCCR;
  37. u_int8_t RSVD0[8];
  38. u_int32_t AB1CR;
  39. u_int32_t AB2CR;
  40. u_int32_t AB3CR;
  41. u_int32_t AB4CR;
  42. u_int8_t RSVD1[32];
  43. u_int32_t NIRR;
  44. u_int32_t NIMR;
  45. u_int32_t NIMSR;
  46. u_int32_t NIMCR;
  47. u_int8_t RSVD2[16];
  48. u_int32_t NANDFCR;
  49. u_int32_t NANDFSR;
  50. u_int8_t RSVD3[8];
  51. u_int32_t NANDF1ECC;
  52. u_int32_t NANDF2ECC;
  53. u_int32_t NANDF3ECC;
  54. u_int32_t NANDF4ECC;
  55. u_int8_t RSVD4[4];
  56. u_int32_t IODFTECR;
  57. u_int32_t IODFTGCR;
  58. u_int8_t RSVD5[4];
  59. u_int32_t IODFTMRLR;
  60. u_int32_t IODFTMRMR;
  61. u_int32_t IODFTMRMSBR;
  62. u_int8_t RSVD6[20];
  63. u_int32_t MODRNR;
  64. u_int8_t RSVD7[76];
  65. u_int32_t CE0DATA;
  66. u_int32_t CE0ALE;
  67. u_int32_t CE0CLE;
  68. u_int8_t RSVD8[4];
  69. u_int32_t CE1DATA;
  70. u_int32_t CE1ALE;
  71. u_int32_t CE1CLE;
  72. u_int8_t RSVD9[4];
  73. u_int32_t CE2DATA;
  74. u_int32_t CE2ALE;
  75. u_int32_t CE2CLE;
  76. u_int8_t RSVD10[4];
  77. u_int32_t CE3DATA;
  78. u_int32_t CE3ALE;
  79. u_int32_t CE3CLE;
  80. } nand_registers;
  81. typedef volatile nand_registers *nandregs;
  82. #define NAND_READ_START 0x00
  83. #define NAND_READ_END 0x30
  84. #define NAND_STATUS 0x70
  85. #ifdef CFG_NAND_HW_ECC
  86. #define NAND_Ecc_P1e (1 << 0)
  87. #define NAND_Ecc_P2e (1 << 1)
  88. #define NAND_Ecc_P4e (1 << 2)
  89. #define NAND_Ecc_P8e (1 << 3)
  90. #define NAND_Ecc_P16e (1 << 4)
  91. #define NAND_Ecc_P32e (1 << 5)
  92. #define NAND_Ecc_P64e (1 << 6)
  93. #define NAND_Ecc_P128e (1 << 7)
  94. #define NAND_Ecc_P256e (1 << 8)
  95. #define NAND_Ecc_P512e (1 << 9)
  96. #define NAND_Ecc_P1024e (1 << 10)
  97. #define NAND_Ecc_P2048e (1 << 11)
  98. #define NAND_Ecc_P1o (1 << 16)
  99. #define NAND_Ecc_P2o (1 << 17)
  100. #define NAND_Ecc_P4o (1 << 18)
  101. #define NAND_Ecc_P8o (1 << 19)
  102. #define NAND_Ecc_P16o (1 << 20)
  103. #define NAND_Ecc_P32o (1 << 21)
  104. #define NAND_Ecc_P64o (1 << 22)
  105. #define NAND_Ecc_P128o (1 << 23)
  106. #define NAND_Ecc_P256o (1 << 24)
  107. #define NAND_Ecc_P512o (1 << 25)
  108. #define NAND_Ecc_P1024o (1 << 26)
  109. #define NAND_Ecc_P2048o (1 << 27)
  110. #define TF(v) (v ? 1 : 0)
  111. #define P2048e(a) (TF(a & NAND_Ecc_P2048e) << 0)
  112. #define P2048o(a) (TF(a & NAND_Ecc_P2048o) << 1)
  113. #define P1e(a) (TF(a & NAND_Ecc_P1e) << 2)
  114. #define P1o(a) (TF(a & NAND_Ecc_P1o) << 3)
  115. #define P2e(a) (TF(a & NAND_Ecc_P2e) << 4)
  116. #define P2o(a) (TF(a & NAND_Ecc_P2o) << 5)
  117. #define P4e(a) (TF(a & NAND_Ecc_P4e) << 6)
  118. #define P4o(a) (TF(a & NAND_Ecc_P4o) << 7)
  119. #define P8e(a) (TF(a & NAND_Ecc_P8e) << 0)
  120. #define P8o(a) (TF(a & NAND_Ecc_P8o) << 1)
  121. #define P16e(a) (TF(a & NAND_Ecc_P16e) << 2)
  122. #define P16o(a) (TF(a & NAND_Ecc_P16o) << 3)
  123. #define P32e(a) (TF(a & NAND_Ecc_P32e) << 4)
  124. #define P32o(a) (TF(a & NAND_Ecc_P32o) << 5)
  125. #define P64e(a) (TF(a & NAND_Ecc_P64e) << 6)
  126. #define P64o(a) (TF(a & NAND_Ecc_P64o) << 7)
  127. #define P128e(a) (TF(a & NAND_Ecc_P128e) << 0)
  128. #define P128o(a) (TF(a & NAND_Ecc_P128o) << 1)
  129. #define P256e(a) (TF(a & NAND_Ecc_P256e) << 2)
  130. #define P256o(a) (TF(a & NAND_Ecc_P256o) << 3)
  131. #define P512e(a) (TF(a & NAND_Ecc_P512e) << 4)
  132. #define P512o(a) (TF(a & NAND_Ecc_P512o) << 5)
  133. #define P1024e(a) (TF(a & NAND_Ecc_P1024e) << 6)
  134. #define P1024o(a) (TF(a & NAND_Ecc_P1024o) << 7)
  135. #define P8e_s(a) (TF(a & NAND_Ecc_P8e) << 0)
  136. #define P8o_s(a) (TF(a & NAND_Ecc_P8o) << 1)
  137. #define P16e_s(a) (TF(a & NAND_Ecc_P16e) << 2)
  138. #define P16o_s(a) (TF(a & NAND_Ecc_P16o) << 3)
  139. #define P1e_s(a) (TF(a & NAND_Ecc_P1e) << 4)
  140. #define P1o_s(a) (TF(a & NAND_Ecc_P1o) << 5)
  141. #define P2e_s(a) (TF(a & NAND_Ecc_P2e) << 6)
  142. #define P2o_s(a) (TF(a & NAND_Ecc_P2o) << 7)
  143. #define P4e_s(a) (TF(a & NAND_Ecc_P4e) << 0)
  144. #define P4o_s(a) (TF(a & NAND_Ecc_P4o) << 1)
  145. #endif
  146. #endif