Skip to content

Commit 9fe4e0d

Browse files
981213miquelraynal
authored andcommitted
mtd: rawnand: fix ecc parameters for mt7622
According to the datasheet, mt7622 only has 5 ECC capabilities instead of 7, and the decoding error register is arranged as follows: +------+---------+---------+---------+---------+ | Bits | 19:15 | 14:10 | 9:5 | 4:0 | +------+---------+---------+---------+---------+ | Name | ERRNUM3 | ERRNUM2 | ERRNUM1 | ERRNUM0 | +------+---------+---------+---------+---------+ This means err_mask should be 0x1f instead of 0x3f and the number of bits shifted in mtk_ecc_get_stats should be 5 instead of 8. This commit introduces err_shift for the difference in this register and fix other existing parameters. Public MT7622 reference manual can be found on [0] and the info this commit is based on is from page 656 and page 660. [0]: https://wiki.banana-pi.org/Banana_Pi_BPI-R64#Documents Fixes: 98dea8d ("mtd: nand: mtk: Support MT7622 NAND flash controller.") Signed-off-by: Chuanhong Guo <gch981213@gmail.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20220402160315.919094-1-gch981213@gmail.com
1 parent 3123109 commit 9fe4e0d

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/mtd/nand/raw/mtk_ecc.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
struct mtk_ecc_caps {
4545
u32 err_mask;
46+
u32 err_shift;
4647
const u8 *ecc_strength;
4748
const u32 *ecc_regs;
4849
u8 num_ecc_strength;
@@ -76,7 +77,7 @@ static const u8 ecc_strength_mt2712[] = {
7677
};
7778

7879
static const u8 ecc_strength_mt7622[] = {
79-
4, 6, 8, 10, 12, 14, 16
80+
4, 6, 8, 10, 12
8081
};
8182

8283
enum mtk_ecc_regs {
@@ -221,7 +222,7 @@ void mtk_ecc_get_stats(struct mtk_ecc *ecc, struct mtk_ecc_stats *stats,
221222
for (i = 0; i < sectors; i++) {
222223
offset = (i >> 2) << 2;
223224
err = readl(ecc->regs + ECC_DECENUM0 + offset);
224-
err = err >> ((i % 4) * 8);
225+
err = err >> ((i % 4) * ecc->caps->err_shift);
225226
err &= ecc->caps->err_mask;
226227
if (err == ecc->caps->err_mask) {
227228
/* uncorrectable errors */
@@ -449,6 +450,7 @@ EXPORT_SYMBOL(mtk_ecc_get_parity_bits);
449450

450451
static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = {
451452
.err_mask = 0x3f,
453+
.err_shift = 8,
452454
.ecc_strength = ecc_strength_mt2701,
453455
.ecc_regs = mt2701_ecc_regs,
454456
.num_ecc_strength = 20,
@@ -459,6 +461,7 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = {
459461

460462
static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = {
461463
.err_mask = 0x7f,
464+
.err_shift = 8,
462465
.ecc_strength = ecc_strength_mt2712,
463466
.ecc_regs = mt2712_ecc_regs,
464467
.num_ecc_strength = 23,
@@ -468,10 +471,11 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = {
468471
};
469472

470473
static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = {
471-
.err_mask = 0x3f,
474+
.err_mask = 0x1f,
475+
.err_shift = 5,
472476
.ecc_strength = ecc_strength_mt7622,
473477
.ecc_regs = mt7622_ecc_regs,
474-
.num_ecc_strength = 7,
478+
.num_ecc_strength = 5,
475479
.ecc_mode_shift = 4,
476480
.parity_bits = 13,
477481
.pg_irq_sel = 0,

0 commit comments

Comments
 (0)