atmel_nand_ecc.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * Error Corrected Code Controller (ECC) - System peripherals regsters.
  3. * Based on AT91SAM9260 datasheet revision B.
  4. *
  5. * Copyright (C) 2007 Andrew Victor
  6. * Copyright (C) 2007 - 2012 Atmel Corporation.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. */
  13. #ifndef ATMEL_NAND_ECC_H
  14. #define ATMEL_NAND_ECC_H
  15. #define ATMEL_ECC_CR 0x00 /* Control register */
  16. #define ATMEL_ECC_RST (1 << 0) /* Reset parity */
  17. #define ATMEL_ECC_MR 0x04 /* Mode register */
  18. #define ATMEL_ECC_PAGESIZE (3 << 0) /* Page Size */
  19. #define ATMEL_ECC_PAGESIZE_528 (0)
  20. #define ATMEL_ECC_PAGESIZE_1056 (1)
  21. #define ATMEL_ECC_PAGESIZE_2112 (2)
  22. #define ATMEL_ECC_PAGESIZE_4224 (3)
  23. #define ATMEL_ECC_SR 0x08 /* Status register */
  24. #define ATMEL_ECC_RECERR (1 << 0) /* Recoverable Error */
  25. #define ATMEL_ECC_ECCERR (1 << 1) /* ECC Single Bit Error */
  26. #define ATMEL_ECC_MULERR (1 << 2) /* Multiple Errors */
  27. #define ATMEL_ECC_PR 0x0c /* Parity register */
  28. #define ATMEL_ECC_BITADDR (0xf << 0) /* Bit Error Address */
  29. #define ATMEL_ECC_WORDADDR (0xfff << 4) /* Word Error Address */
  30. #define ATMEL_ECC_NPR 0x10 /* NParity register */
  31. #define ATMEL_ECC_NPARITY (0xffff << 0) /* NParity */
  32. /* PMECC Register Definitions */
  33. #define ATMEL_PMECC_CFG 0x000 /* Configuration Register */
  34. #define PMECC_CFG_BCH_ERR2 (0 << 0)
  35. #define PMECC_CFG_BCH_ERR4 (1 << 0)
  36. #define PMECC_CFG_BCH_ERR8 (2 << 0)
  37. #define PMECC_CFG_BCH_ERR12 (3 << 0)
  38. #define PMECC_CFG_BCH_ERR24 (4 << 0)
  39. #define PMECC_CFG_SECTOR512 (0 << 4)
  40. #define PMECC_CFG_SECTOR1024 (1 << 4)
  41. #define PMECC_CFG_PAGE_1SECTOR (0 << 8)
  42. #define PMECC_CFG_PAGE_2SECTORS (1 << 8)
  43. #define PMECC_CFG_PAGE_4SECTORS (2 << 8)
  44. #define PMECC_CFG_PAGE_8SECTORS (3 << 8)
  45. #define PMECC_CFG_READ_OP (0 << 12)
  46. #define PMECC_CFG_WRITE_OP (1 << 12)
  47. #define PMECC_CFG_SPARE_ENABLE (1 << 16)
  48. #define PMECC_CFG_SPARE_DISABLE (0 << 16)
  49. #define PMECC_CFG_AUTO_ENABLE (1 << 20)
  50. #define PMECC_CFG_AUTO_DISABLE (0 << 20)
  51. #define ATMEL_PMECC_SAREA 0x004 /* Spare area size */
  52. #define ATMEL_PMECC_SADDR 0x008 /* PMECC starting address */
  53. #define ATMEL_PMECC_EADDR 0x00c /* PMECC ending address */
  54. #define ATMEL_PMECC_CLK 0x010 /* PMECC clock control */
  55. #define PMECC_CLK_133MHZ (2 << 0)
  56. #define ATMEL_PMECC_CTRL 0x014 /* PMECC control register */
  57. #define PMECC_CTRL_RST (1 << 0)
  58. #define PMECC_CTRL_DATA (1 << 1)
  59. #define PMECC_CTRL_USER (1 << 2)
  60. #define PMECC_CTRL_ENABLE (1 << 4)
  61. #define PMECC_CTRL_DISABLE (1 << 5)
  62. #define ATMEL_PMECC_SR 0x018 /* PMECC status register */
  63. #define PMECC_SR_BUSY (1 << 0)
  64. #define PMECC_SR_ENABLE (1 << 4)
  65. #define ATMEL_PMECC_IER 0x01c /* PMECC interrupt enable */
  66. #define PMECC_IER_ENABLE (1 << 0)
  67. #define ATMEL_PMECC_IDR 0x020 /* PMECC interrupt disable */
  68. #define PMECC_IER_DISABLE (1 << 0)
  69. #define ATMEL_PMECC_IMR 0x024 /* PMECC interrupt mask */
  70. #define PMECC_IER_MASK (1 << 0)
  71. #define ATMEL_PMECC_ISR 0x028 /* PMECC interrupt status */
  72. #define ATMEL_PMECC_ECCx 0x040 /* PMECC ECC x */
  73. #define ATMEL_PMECC_REMx 0x240 /* PMECC REM x */
  74. /* PMERRLOC Register Definitions */
  75. #define ATMEL_PMERRLOC_ELCFG 0x000 /* Error location config */
  76. #define PMERRLOC_ELCFG_SECTOR_512 (0 << 0)
  77. #define PMERRLOC_ELCFG_SECTOR_1024 (1 << 0)
  78. #define PMERRLOC_ELCFG_NUM_ERRORS(n) ((n) << 16)
  79. #define ATMEL_PMERRLOC_ELPRIM 0x004 /* Error location primitive */
  80. #define ATMEL_PMERRLOC_ELEN 0x008 /* Error location enable */
  81. #define ATMEL_PMERRLOC_ELDIS 0x00c /* Error location disable */
  82. #define PMERRLOC_DISABLE (1 << 0)
  83. #define ATMEL_PMERRLOC_ELSR 0x010 /* Error location status */
  84. #define PMERRLOC_ELSR_BUSY (1 << 0)
  85. #define ATMEL_PMERRLOC_ELIER 0x014 /* Error location int enable */
  86. #define ATMEL_PMERRLOC_ELIDR 0x018 /* Error location int disable */
  87. #define ATMEL_PMERRLOC_ELIMR 0x01c /* Error location int mask */
  88. #define ATMEL_PMERRLOC_ELISR 0x020 /* Error location int status */
  89. #define PMERRLOC_ERR_NUM_MASK (0x1f << 8)
  90. #define PMERRLOC_CALC_DONE (1 << 0)
  91. #define ATMEL_PMERRLOC_SIGMAx 0x028 /* Error location SIGMA x */
  92. #define ATMEL_PMERRLOC_ELx 0x08c /* Error location x */
  93. /* Register access macros for PMECC */
  94. #define pmecc_readl_relaxed(addr, reg) \
  95. readl_relaxed((addr) + ATMEL_PMECC_##reg)
  96. #define pmecc_writel(addr, reg, value) \
  97. writel((value), (addr) + ATMEL_PMECC_##reg)
  98. #define pmecc_readb_ecc_relaxed(addr, sector, n) \
  99. readb_relaxed((addr) + ATMEL_PMECC_ECCx + ((sector) * 0x40) + (n))
  100. #define pmecc_readl_rem_relaxed(addr, sector, n) \
  101. readl_relaxed((addr) + ATMEL_PMECC_REMx + ((sector) * 0x40) + ((n) * 4))
  102. #define pmerrloc_readl_relaxed(addr, reg) \
  103. readl_relaxed((addr) + ATMEL_PMERRLOC_##reg)
  104. #define pmerrloc_writel(addr, reg, value) \
  105. writel((value), (addr) + ATMEL_PMERRLOC_##reg)
  106. #define pmerrloc_writel_sigma_relaxed(addr, n, value) \
  107. writel_relaxed((value), (addr) + ATMEL_PMERRLOC_SIGMAx + ((n) * 4))
  108. #define pmerrloc_readl_sigma_relaxed(addr, n) \
  109. readl_relaxed((addr) + ATMEL_PMERRLOC_SIGMAx + ((n) * 4))
  110. #define pmerrloc_readl_el_relaxed(addr, n) \
  111. readl_relaxed((addr) + ATMEL_PMERRLOC_ELx + ((n) * 4))
  112. /* Galois field dimension */
  113. #define PMECC_GF_DIMENSION_13 13
  114. #define PMECC_GF_DIMENSION_14 14
  115. /* Primitive Polynomial used by PMECC */
  116. #define PMECC_GF_13_PRIMITIVE_POLY 0x201b
  117. #define PMECC_GF_14_PRIMITIVE_POLY 0x4443
  118. #define PMECC_LOOKUP_TABLE_SIZE_512 0x2000
  119. #define PMECC_LOOKUP_TABLE_SIZE_1024 0x4000
  120. /* Time out value for reading PMECC status register */
  121. #define PMECC_MAX_TIMEOUT_MS 100
  122. /* Reserved bytes in oob area */
  123. #define PMECC_OOB_RESERVED_BYTES 2
  124. #endif