atmel_nand_ecc.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Error Corrected Code Controller (ECC) - System peripherals regsters.
  3. * Based on AT91SAM9260 datasheet revision B.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. */
  10. #ifndef ATMEL_NAND_ECC_H
  11. #define ATMEL_NAND_ECC_H
  12. #define ATMEL_ECC_CR 0x00 /* Control register */
  13. #define ATMEL_ECC_RST (1 << 0) /* Reset parity */
  14. #define ATMEL_ECC_MR 0x04 /* Mode register */
  15. #define ATMEL_ECC_PAGESIZE (3 << 0) /* Page Size */
  16. #define ATMEL_ECC_PAGESIZE_528 (0)
  17. #define ATMEL_ECC_PAGESIZE_1056 (1)
  18. #define ATMEL_ECC_PAGESIZE_2112 (2)
  19. #define ATMEL_ECC_PAGESIZE_4224 (3)
  20. #define ATMEL_ECC_SR 0x08 /* Status register */
  21. #define ATMEL_ECC_RECERR (1 << 0) /* Recoverable Error */
  22. #define ATMEL_ECC_ECCERR (1 << 1) /* ECC Single Bit Error */
  23. #define ATMEL_ECC_MULERR (1 << 2) /* Multiple Errors */
  24. #define ATMEL_ECC_PR 0x0c /* Parity register */
  25. #define ATMEL_ECC_BITADDR (0xf << 0) /* Bit Error Address */
  26. #define ATMEL_ECC_WORDADDR (0xfff << 4) /* Word Error Address */
  27. #define ATMEL_ECC_NPR 0x10 /* NParity register */
  28. #define ATMEL_ECC_NPARITY (0xffff << 0) /* NParity */
  29. /* Register access macros for PMECC */
  30. #define pmecc_readl(addr, reg) \
  31. readl(&addr->reg)
  32. #define pmecc_writel(addr, reg, value) \
  33. writel((value), &addr->reg)
  34. /* PMECC Register Definitions */
  35. #define PMECC_MAX_SECTOR_NUM 8
  36. struct pmecc_regs {
  37. u32 cfg; /* 0x00 PMECC Configuration Register */
  38. u32 sarea; /* 0x04 PMECC Spare Area Size Register */
  39. u32 saddr; /* 0x08 PMECC Start Address Register */
  40. u32 eaddr; /* 0x0C PMECC End Address Register */
  41. u32 clk; /* 0x10 PMECC Clock Control Register */
  42. u32 ctrl; /* 0x14 PMECC Control Register */
  43. u32 sr; /* 0x18 PMECC Status Register */
  44. u32 ier; /* 0x1C PMECC Interrupt Enable Register */
  45. u32 idr; /* 0x20 PMECC Interrupt Disable Register */
  46. u32 imr; /* 0x24 PMECC Interrupt Mask Register */
  47. u32 isr; /* 0x28 PMECC Interrupt Status Register */
  48. u32 reserved0[5]; /* 0x2C-0x3C Reserved */
  49. /* 0x40 + sector_num * (0x40), Redundancy Registers */
  50. struct {
  51. u8 ecc[44]; /* PMECC Generated Redundancy Byte Per Sector */
  52. u32 reserved1[5];
  53. } ecc_port[PMECC_MAX_SECTOR_NUM];
  54. /* 0x240 + sector_num * (0x40) Remainder Registers */
  55. struct {
  56. u32 rem[12];
  57. u32 reserved2[4];
  58. } rem_port[PMECC_MAX_SECTOR_NUM];
  59. u32 reserved3[16]; /* 0x440-0x47C Reserved */
  60. };
  61. /* For PMECC Configuration Register */
  62. #define PMECC_CFG_BCH_ERR2 (0 << 0)
  63. #define PMECC_CFG_BCH_ERR4 (1 << 0)
  64. #define PMECC_CFG_BCH_ERR8 (2 << 0)
  65. #define PMECC_CFG_BCH_ERR12 (3 << 0)
  66. #define PMECC_CFG_BCH_ERR24 (4 << 0)
  67. #define PMECC_CFG_SECTOR512 (0 << 4)
  68. #define PMECC_CFG_SECTOR1024 (1 << 4)
  69. #define PMECC_CFG_PAGE_1SECTOR (0 << 8)
  70. #define PMECC_CFG_PAGE_2SECTORS (1 << 8)
  71. #define PMECC_CFG_PAGE_4SECTORS (2 << 8)
  72. #define PMECC_CFG_PAGE_8SECTORS (3 << 8)
  73. #define PMECC_CFG_READ_OP (0 << 12)
  74. #define PMECC_CFG_WRITE_OP (1 << 12)
  75. #define PMECC_CFG_SPARE_ENABLE (1 << 16)
  76. #define PMECC_CFG_SPARE_DISABLE (0 << 16)
  77. #define PMECC_CFG_AUTO_ENABLE (1 << 20)
  78. #define PMECC_CFG_AUTO_DISABLE (0 << 20)
  79. /* For PMECC Clock Control Register */
  80. #define PMECC_CLK_133MHZ (2 << 0)
  81. /* For PMECC Control Register */
  82. #define PMECC_CTRL_RST (1 << 0)
  83. #define PMECC_CTRL_DATA (1 << 1)
  84. #define PMECC_CTRL_USER (1 << 2)
  85. #define PMECC_CTRL_ENABLE (1 << 4)
  86. #define PMECC_CTRL_DISABLE (1 << 5)
  87. /* For PMECC Status Register */
  88. #define PMECC_SR_BUSY (1 << 0)
  89. #define PMECC_SR_ENABLE (1 << 4)
  90. /* PMERRLOC Register Definitions */
  91. struct pmecc_errloc_regs {
  92. u32 elcfg; /* 0x00 Error Location Configuration Register */
  93. u32 elprim; /* 0x04 Error Location Primitive Register */
  94. u32 elen; /* 0x08 Error Location Enable Register */
  95. u32 eldis; /* 0x0C Error Location Disable Register */
  96. u32 elsr; /* 0x10 Error Location Status Register */
  97. u32 elier; /* 0x14 Error Location Interrupt Enable Register */
  98. u32 elidr; /* 0x08 Error Location Interrupt Disable Register */
  99. u32 elimr; /* 0x0C Error Location Interrupt Mask Register */
  100. u32 elisr; /* 0x20 Error Location Interrupt Status Register */
  101. u32 reserved0; /* 0x24 Reserved */
  102. u32 sigma[25]; /* 0x28-0x88 Error Location Sigma Registers */
  103. u32 el[24]; /* 0x8C-0xE8 Error Location Registers */
  104. u32 reserved1[5]; /* 0xEC-0xFC Reserved */
  105. };
  106. /* For Error Location Configuration Register */
  107. #define PMERRLOC_ELCFG_SECTOR_512 (0 << 0)
  108. #define PMERRLOC_ELCFG_SECTOR_1024 (1 << 0)
  109. #define PMERRLOC_ELCFG_NUM_ERRORS(n) ((n) << 16)
  110. /* For Error Location Disable Register */
  111. #define PMERRLOC_DISABLE (1 << 0)
  112. /* For Error Location Interrupt Status Register */
  113. #define PMERRLOC_ERR_NUM_MASK (0x1f << 8)
  114. #define PMERRLOC_CALC_DONE (1 << 0)
  115. /* Galois field dimension */
  116. #define PMECC_GF_DIMENSION_13 13
  117. #define PMECC_GF_DIMENSION_14 14
  118. #define PMECC_INDEX_TABLE_SIZE_512 0x2000
  119. #define PMECC_INDEX_TABLE_SIZE_1024 0x4000
  120. #define PMECC_MAX_TIMEOUT_US (100 * 1000)
  121. #endif