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 12 #ifndef __DRIVERS_MTD_NAND_MTK_ECC_H__ 13 #define __DRIVERS_MTD_NAND_MTK_ECC_H__ 14 15 #include <linux/types.h> 16 17 enum mtk_ecc_mode {ECC_DMA_MODE = 0, ECC_NFI_MODE = 1}; 18 enum mtk_ecc_operation {ECC_ENCODE, ECC_DECODE}; 19 20 struct device_node; 21 struct mtk_ecc; 22 23 struct mtk_ecc_stats { 24 u32 corrected; 25 u32 bitflips; 26 u32 failed; 27 }; 28 29 struct mtk_ecc_config { 30 enum mtk_ecc_operation op; 31 enum mtk_ecc_mode mode; 32 dma_addr_t addr; 33 u32 strength; 34 u32 sectors; 35 u32 len; 36 }; 37 38 int mtk_ecc_encode(struct mtk_ecc *, struct mtk_ecc_config *, u8 *, u32); 39 void mtk_ecc_get_stats(struct mtk_ecc *, struct mtk_ecc_stats *, int); 40 int mtk_ecc_wait_done(struct mtk_ecc *, enum mtk_ecc_operation); 41 int mtk_ecc_enable(struct mtk_ecc *, struct mtk_ecc_config *); 42 void mtk_ecc_disable(struct mtk_ecc *); 43 void mtk_ecc_adjust_strength(struct mtk_ecc *ecc, u32 *p); 44 unsigned int mtk_ecc_get_parity_bits(struct mtk_ecc *ecc); 45 46 struct mtk_ecc *of_mtk_ecc_get(struct device_node *); 47 void mtk_ecc_release(struct mtk_ecc *); 48 49 #endif 50