elm.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * (C) Copyright 2010-2011 Texas Instruments, <www.ti.com>
  3. * Mansoor Ahamed <mansoor.ahamed@ti.com>
  4. *
  5. * Derived from work done by Rohit Choraria <rohitkc@ti.com> for omap3
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #ifndef __ASM_ARCH_ELM_H
  26. #define __ASM_ARCH_ELM_H
  27. /*
  28. * ELM Module Registers
  29. */
  30. /* ELM registers bit fields */
  31. #define ELM_SYSCONFIG_SOFTRESET_MASK (0x2)
  32. #define ELM_SYSCONFIG_SOFTRESET (0x2)
  33. #define ELM_SYSSTATUS_RESETDONE_MASK (0x1)
  34. #define ELM_SYSSTATUS_RESETDONE (0x1)
  35. #define ELM_LOCATION_CONFIG_ECC_BCH_LEVEL_MASK (0x3)
  36. #define ELM_LOCATION_CONFIG_ECC_SIZE_MASK (0x7FF0000)
  37. #define ELM_LOCATION_CONFIG_ECC_SIZE_POS (16)
  38. #define ELM_SYNDROME_FRAGMENT_6_SYNDROME_VALID (0x00010000)
  39. #define ELM_LOCATION_STATUS_ECC_CORRECTABLE_MASK (0x100)
  40. #define ELM_LOCATION_STATUS_ECC_NB_ERRORS_MASK (0x1F)
  41. #ifndef __ASSEMBLY__
  42. enum bch_level {
  43. BCH_4_BIT = 0,
  44. BCH_8_BIT,
  45. BCH_16_BIT
  46. };
  47. /* BCH syndrome registers */
  48. struct syndrome {
  49. u32 syndrome_fragment_x[7]; /* 0x400, 0x404.... 0x418 */
  50. u8 res1[36]; /* 0x41c */
  51. };
  52. /* BCH error status & location register */
  53. struct location {
  54. u32 location_status; /* 0x800 */
  55. u8 res1[124]; /* 0x804 */
  56. u32 error_location_x[16]; /* 0x880.... */
  57. u8 res2[64]; /* 0x8c0 */
  58. };
  59. /* BCH ELM register map - do not try to allocate memmory for this structure.
  60. * We have used plenty of reserved variables to fill the slots in the ELM
  61. * register memory map.
  62. * Directly initialize the struct pointer to ELM base address.
  63. */
  64. struct elm {
  65. u32 rev; /* 0x000 */
  66. u8 res1[12]; /* 0x004 */
  67. u32 sysconfig; /* 0x010 */
  68. u32 sysstatus; /* 0x014 */
  69. u32 irqstatus; /* 0x018 */
  70. u32 irqenable; /* 0x01c */
  71. u32 location_config; /* 0x020 */
  72. u8 res2[92]; /* 0x024 */
  73. u32 page_ctrl; /* 0x080 */
  74. u8 res3[892]; /* 0x084 */
  75. struct syndrome syndrome_fragments[8]; /* 0x400 */
  76. u8 res4[512]; /* 0x600 */
  77. struct location error_location[8]; /* 0x800 */
  78. };
  79. int elm_check_error(u8 *syndrome, u32 nibbles, u32 *error_count,
  80. u32 *error_locations);
  81. int elm_config(enum bch_level level);
  82. void elm_reset(void);
  83. void elm_init(void);
  84. #endif /* __ASSEMBLY__ */
  85. #endif /* __ASM_ARCH_ELM_H */