mtk_ecc.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * MTK SDG1 ECC controller
  3. *
  4. * Copyright (c) 2016 Mediatek
  5. * Authors: Xiaolei Li <xiaolei.li@mediatek.com>
  6. * Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #ifndef __DRIVERS_MTD_NAND_MTK_ECC_H__
  12. #define __DRIVERS_MTD_NAND_MTK_ECC_H__
  13. #include <linux/types.h>
  14. #define ECC_PARITY_BITS (14)
  15. enum mtk_ecc_mode {ECC_DMA_MODE = 0, ECC_NFI_MODE = 1};
  16. enum mtk_ecc_operation {ECC_ENCODE, ECC_DECODE};
  17. struct device_node;
  18. struct mtk_ecc;
  19. struct mtk_ecc_stats {
  20. u32 corrected;
  21. u32 bitflips;
  22. u32 failed;
  23. };
  24. struct mtk_ecc_config {
  25. enum mtk_ecc_operation op;
  26. enum mtk_ecc_mode mode;
  27. dma_addr_t addr;
  28. u32 strength;
  29. u32 sectors;
  30. u32 len;
  31. };
  32. int mtk_ecc_encode(struct mtk_ecc *, struct mtk_ecc_config *, u8 *, u32);
  33. void mtk_ecc_get_stats(struct mtk_ecc *, struct mtk_ecc_stats *, int);
  34. int mtk_ecc_wait_done(struct mtk_ecc *, enum mtk_ecc_operation);
  35. int mtk_ecc_enable(struct mtk_ecc *, struct mtk_ecc_config *);
  36. void mtk_ecc_disable(struct mtk_ecc *);
  37. void mtk_ecc_adjust_strength(u32 *);
  38. struct mtk_ecc *of_mtk_ecc_get(struct device_node *);
  39. void mtk_ecc_release(struct mtk_ecc *);
  40. #endif