elm.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * BCH Error Location Module
  3. *
  4. * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #ifndef __ELM_H
  18. #define __ELM_H
  19. enum bch_ecc {
  20. BCH4_ECC = 0,
  21. BCH8_ECC,
  22. BCH16_ECC,
  23. };
  24. /* ELM support 8 error syndrome process */
  25. #define ERROR_VECTOR_MAX 8
  26. /**
  27. * struct elm_errorvec - error vector for elm
  28. * @error_reported: set true for vectors error is reported
  29. * @error_uncorrectable: number of uncorrectable errors
  30. * @error_count: number of correctable errors in the sector
  31. * @error_loc: buffer for error location
  32. *
  33. */
  34. struct elm_errorvec {
  35. bool error_reported;
  36. bool error_uncorrectable;
  37. int error_count;
  38. int error_loc[16];
  39. };
  40. #if IS_ENABLED(CONFIG_MTD_NAND_OMAP_BCH)
  41. void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
  42. struct elm_errorvec *err_vec);
  43. int elm_config(struct device *dev, enum bch_ecc bch_type,
  44. int ecc_steps, int ecc_step_size, int ecc_syndrome_size);
  45. #else
  46. static inline void
  47. elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
  48. struct elm_errorvec *err_vec)
  49. {
  50. }
  51. static inline int elm_config(struct device *dev, enum bch_ecc bch_type,
  52. int ecc_steps, int ecc_step_size,
  53. int ecc_syndrome_size)
  54. {
  55. return -ENOSYS;
  56. }
  57. #endif /* CONFIG_MTD_NAND_ECC_BCH */
  58. #endif /* __ELM_H */