Skip to content

Commit 4d21176

Browse files
mtk-xiangshengmiquelraynal
authored andcommitted
mtd: nand: ecc-mtk: Add ECC support fot MT7986 IC
Add ECC support fot MT7986 IC, and change err_mask value with GENMASK macro. Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20230201021500.26769-6-xiangsheng.hou@mediatek.com
1 parent 70d3cf7 commit 4d21176

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

drivers/mtd/nand/ecc-mtk.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
#define ECC_IDLE_REG(op) ((op) == ECC_ENCODE ? ECC_ENCIDLE : ECC_DECIDLE)
4141
#define ECC_CTL_REG(op) ((op) == ECC_ENCODE ? ECC_ENCCON : ECC_DECCON)
4242

43+
#define ECC_ERRMASK_MT7622 GENMASK(4, 0)
44+
#define ECC_ERRMASK_MT2701 GENMASK(5, 0)
45+
#define ECC_ERRMASK_MT2712 GENMASK(6, 0)
46+
4347
struct mtk_ecc_caps {
4448
u32 err_mask;
4549
u32 err_shift;
@@ -79,6 +83,10 @@ static const u8 ecc_strength_mt7622[] = {
7983
4, 6, 8, 10, 12
8084
};
8185

86+
static const u8 ecc_strength_mt7986[] = {
87+
4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24
88+
};
89+
8290
enum mtk_ecc_regs {
8391
ECC_ENCPAR00,
8492
ECC_ENCIRQ_EN,
@@ -451,7 +459,7 @@ unsigned int mtk_ecc_get_parity_bits(struct mtk_ecc *ecc)
451459
EXPORT_SYMBOL(mtk_ecc_get_parity_bits);
452460

453461
static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = {
454-
.err_mask = 0x3f,
462+
.err_mask = ECC_ERRMASK_MT2701,
455463
.err_shift = 8,
456464
.ecc_strength = ecc_strength_mt2701,
457465
.ecc_regs = mt2701_ecc_regs,
@@ -462,7 +470,7 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = {
462470
};
463471

464472
static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = {
465-
.err_mask = 0x7f,
473+
.err_mask = ECC_ERRMASK_MT2712,
466474
.err_shift = 8,
467475
.ecc_strength = ecc_strength_mt2712,
468476
.ecc_regs = mt2712_ecc_regs,
@@ -473,7 +481,7 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = {
473481
};
474482

475483
static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = {
476-
.err_mask = 0x1f,
484+
.err_mask = ECC_ERRMASK_MT7622,
477485
.err_shift = 5,
478486
.ecc_strength = ecc_strength_mt7622,
479487
.ecc_regs = mt7622_ecc_regs,
@@ -483,6 +491,17 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = {
483491
.pg_irq_sel = 0,
484492
};
485493

494+
static const struct mtk_ecc_caps mtk_ecc_caps_mt7986 = {
495+
.err_mask = ECC_ERRMASK_MT7622,
496+
.err_shift = 8,
497+
.ecc_strength = ecc_strength_mt7986,
498+
.ecc_regs = mt2712_ecc_regs,
499+
.num_ecc_strength = 11,
500+
.ecc_mode_shift = 5,
501+
.parity_bits = 14,
502+
.pg_irq_sel = 1,
503+
};
504+
486505
static const struct of_device_id mtk_ecc_dt_match[] = {
487506
{
488507
.compatible = "mediatek,mt2701-ecc",
@@ -493,6 +512,9 @@ static const struct of_device_id mtk_ecc_dt_match[] = {
493512
}, {
494513
.compatible = "mediatek,mt7622-ecc",
495514
.data = &mtk_ecc_caps_mt7622,
515+
}, {
516+
.compatible = "mediatek,mt7986-ecc",
517+
.data = &mtk_ecc_caps_mt7986,
496518
},
497519
{},
498520
};

0 commit comments

Comments
 (0)