2019-06-24 09:38:56 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
|
2016-06-14 23:50:51 +08:00
|
|
|
/*
|
|
|
|
* MTK SDG1 ECC controller
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016 Mediatek
|
|
|
|
* Authors: Xiaolei Li <xiaolei.li@mediatek.com>
|
|
|
|
* Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DRIVERS_MTD_NAND_MTK_ECC_H__
|
|
|
|
#define __DRIVERS_MTD_NAND_MTK_ECC_H__
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
enum mtk_ecc_mode {ECC_DMA_MODE = 0, ECC_NFI_MODE = 1};
|
|
|
|
enum mtk_ecc_operation {ECC_ENCODE, ECC_DECODE};
|
|
|
|
|
|
|
|
struct device_node;
|
|
|
|
struct mtk_ecc;
|
|
|
|
|
|
|
|
struct mtk_ecc_stats {
|
|
|
|
u32 corrected;
|
|
|
|
u32 bitflips;
|
|
|
|
u32 failed;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mtk_ecc_config {
|
|
|
|
enum mtk_ecc_operation op;
|
|
|
|
enum mtk_ecc_mode mode;
|
|
|
|
dma_addr_t addr;
|
|
|
|
u32 strength;
|
|
|
|
u32 sectors;
|
|
|
|
u32 len;
|
|
|
|
};
|
|
|
|
|
|
|
|
int mtk_ecc_encode(struct mtk_ecc *, struct mtk_ecc_config *, u8 *, u32);
|
|
|
|
void mtk_ecc_get_stats(struct mtk_ecc *, struct mtk_ecc_stats *, int);
|
|
|
|
int mtk_ecc_wait_done(struct mtk_ecc *, enum mtk_ecc_operation);
|
|
|
|
int mtk_ecc_enable(struct mtk_ecc *, struct mtk_ecc_config *);
|
|
|
|
void mtk_ecc_disable(struct mtk_ecc *);
|
2017-05-31 16:26:40 +08:00
|
|
|
void mtk_ecc_adjust_strength(struct mtk_ecc *ecc, u32 *p);
|
mtd: nand: mtk: Support different MTK NAND flash controller IP
MT7622 uses an MTK's earlier NAND flash controller IP which support
different sector size, max spare size per sector and paraity bits...,
some register's offset and definition also been changed in the NAND
flash controller, this patch is the preparation to support MT7622
NAND flash controller.
MT7622 NFC and ECC engine are similar to MT2701's, except below
differences:
(1)MT7622 NFC's max sector size(ECC data size) is 512 bytes, and
MT2701's is 1024, and MT7622's max sector number is 8.
(2)The parity bit of MT7622 is 13, MT2701 is 14.
(3)MT7622 ECC supports less ECC strength, max to 16 bit ecc strength.
(4)MT7622 supports less spare size per sector, max spare size per
sector is 28 bytes.
(5)Some register's offset are different, include ECC_ENCIRQ_EN,
ECC_ENCIRQ_STA, ECC_DECDONE, ECC_DECIRQ_EN and ECC_DECIRQ_STA.
(6)ENC_MODE of ECC_ENCCNFG register is moved from bit 5-6 to bit 4-5.
Signed-off-by: RogerCC Lin <rogercc.lin@mediatek.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2017-11-30 22:10:44 +08:00
|
|
|
unsigned int mtk_ecc_get_parity_bits(struct mtk_ecc *ecc);
|
2016-06-14 23:50:51 +08:00
|
|
|
|
|
|
|
struct mtk_ecc *of_mtk_ecc_get(struct device_node *);
|
|
|
|
void mtk_ecc_release(struct mtk_ecc *);
|
|
|
|
|
|
|
|
#endif
|