omap_elm.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2010-2011 Texas Instruments, <www.ti.com>
  4. * Mansoor Ahamed <mansoor.ahamed@ti.com>
  5. *
  6. * Derived from work done by Rohit Choraria <rohitkc@ti.com> for omap3
  7. */
  8. #ifndef __ASM_ARCH_ELM_H
  9. #define __ASM_ARCH_ELM_H
  10. /*
  11. * ELM Module Registers
  12. */
  13. /* ELM registers bit fields */
  14. #define ELM_SYSCONFIG_SOFTRESET_MASK (0x2)
  15. #define ELM_SYSCONFIG_SOFTRESET (0x2)
  16. #define ELM_SYSSTATUS_RESETDONE_MASK (0x1)
  17. #define ELM_SYSSTATUS_RESETDONE (0x1)
  18. #define ELM_LOCATION_CONFIG_ECC_BCH_LEVEL_MASK (0x3)
  19. #define ELM_LOCATION_CONFIG_ECC_SIZE_MASK (0x7FF0000)
  20. #define ELM_LOCATION_CONFIG_ECC_SIZE_POS (16)
  21. #define ELM_SYNDROME_FRAGMENT_6_SYNDROME_VALID (0x00010000)
  22. #define ELM_LOCATION_STATUS_ECC_CORRECTABLE_MASK (0x100)
  23. #define ELM_LOCATION_STATUS_ECC_NB_ERRORS_MASK (0x1F)
  24. #define ELM_MAX_CHANNELS 8
  25. #define ELM_MAX_ERROR_COUNT 16
  26. #ifndef __ASSEMBLY__
  27. enum bch_level {
  28. BCH_4_BIT = 0,
  29. BCH_8_BIT,
  30. BCH_16_BIT
  31. };
  32. /* BCH syndrome registers */
  33. struct syndrome {
  34. u32 syndrome_fragment_x[7]; /* 0x400, 0x404.... 0x418 */
  35. u8 res1[36]; /* 0x41c */
  36. };
  37. /* BCH error status & location register */
  38. struct location {
  39. u32 location_status; /* 0x800 */
  40. u8 res1[124]; /* 0x804 */
  41. u32 error_location_x[ELM_MAX_ERROR_COUNT]; /* 0x880, 0x980, .. */
  42. u8 res2[64]; /* 0x8c0 */
  43. };
  44. /* BCH ELM register map - do not try to allocate memmory for this structure.
  45. * We have used plenty of reserved variables to fill the slots in the ELM
  46. * register memory map.
  47. * Directly initialize the struct pointer to ELM base address.
  48. */
  49. struct elm {
  50. u32 rev; /* 0x000 */
  51. u8 res1[12]; /* 0x004 */
  52. u32 sysconfig; /* 0x010 */
  53. u32 sysstatus; /* 0x014 */
  54. u32 irqstatus; /* 0x018 */
  55. u32 irqenable; /* 0x01c */
  56. u32 location_config; /* 0x020 */
  57. u8 res2[92]; /* 0x024 */
  58. u32 page_ctrl; /* 0x080 */
  59. u8 res3[892]; /* 0x084 */
  60. struct syndrome syndrome_fragments[ELM_MAX_CHANNELS]; /* 0x400,0x420 */
  61. u8 res4[512]; /* 0x600 */
  62. struct location error_location[ELM_MAX_CHANNELS]; /* 0x800,0x900 ... */
  63. };
  64. int elm_check_error(u8 *syndrome, enum bch_level bch_type, u32 *error_count,
  65. u32 *error_locations);
  66. int elm_config(enum bch_level level);
  67. void elm_reset(void);
  68. void elm_init(void);
  69. #endif /* __ASSEMBLY__ */
  70. #endif /* __ASM_ARCH_ELM_H */