Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Xiangsheng Hou and committed by
Miquel Raynal
4d21176f 70d3cf76

+25 -3
+25 -3
drivers/mtd/nand/ecc-mtk.c
··· 40 40 #define ECC_IDLE_REG(op) ((op) == ECC_ENCODE ? ECC_ENCIDLE : ECC_DECIDLE) 41 41 #define ECC_CTL_REG(op) ((op) == ECC_ENCODE ? ECC_ENCCON : ECC_DECCON) 42 42 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 + 43 47 struct mtk_ecc_caps { 44 48 u32 err_mask; 45 49 u32 err_shift; ··· 81 77 82 78 static const u8 ecc_strength_mt7622[] = { 83 79 4, 6, 8, 10, 12 80 + }; 81 + 82 + static const u8 ecc_strength_mt7986[] = { 83 + 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24 84 84 }; 85 85 86 86 enum mtk_ecc_regs { ··· 459 451 EXPORT_SYMBOL(mtk_ecc_get_parity_bits); 460 452 461 453 static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = { 462 - .err_mask = 0x3f, 454 + .err_mask = ECC_ERRMASK_MT2701, 463 455 .err_shift = 8, 464 456 .ecc_strength = ecc_strength_mt2701, 465 457 .ecc_regs = mt2701_ecc_regs, ··· 470 462 }; 471 463 472 464 static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = { 473 - .err_mask = 0x7f, 465 + .err_mask = ECC_ERRMASK_MT2712, 474 466 .err_shift = 8, 475 467 .ecc_strength = ecc_strength_mt2712, 476 468 .ecc_regs = mt2712_ecc_regs, ··· 481 473 }; 482 474 483 475 static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = { 484 - .err_mask = 0x1f, 476 + .err_mask = ECC_ERRMASK_MT7622, 485 477 .err_shift = 5, 486 478 .ecc_strength = ecc_strength_mt7622, 487 479 .ecc_regs = mt7622_ecc_regs, ··· 489 481 .ecc_mode_shift = 4, 490 482 .parity_bits = 13, 491 483 .pg_irq_sel = 0, 484 + }; 485 + 486 + static const struct mtk_ecc_caps mtk_ecc_caps_mt7986 = { 487 + .err_mask = ECC_ERRMASK_MT7622, 488 + .err_shift = 8, 489 + .ecc_strength = ecc_strength_mt7986, 490 + .ecc_regs = mt2712_ecc_regs, 491 + .num_ecc_strength = 11, 492 + .ecc_mode_shift = 5, 493 + .parity_bits = 14, 494 + .pg_irq_sel = 1, 492 495 }; 493 496 494 497 static const struct of_device_id mtk_ecc_dt_match[] = { ··· 512 493 }, { 513 494 .compatible = "mediatek,mt7622-ecc", 514 495 .data = &mtk_ecc_caps_mt7622, 496 + }, { 497 + .compatible = "mediatek,mt7986-ecc", 498 + .data = &mtk_ecc_caps_mt7986, 515 499 }, 516 500 {}, 517 501 };