* [PATCH] mtd: rawnand: fix ecc parameters for mt7622
@ 2022-04-02 16:03 Chuanhong Guo
2022-04-04 8:43 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Chuanhong Guo @ 2022-04-02 16:03 UTC (permalink / raw)
To: linux-mtd
Cc: Chuanhong Guo, Miquel Raynal, Richard Weinberger,
Vignesh Raghavendra, Matthias Brugger, Alexandre Belloni,
Pratyush Yadav, Paul Cercueil, Yu Kuai, Cai Huoqing, RogerCC Lin,
Boris Brezillon, moderated list:ARM/Mediatek SoC support,
moderated list:ARM/Mediatek SoC support, open list
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: 98dea8d71931 ("mtd: nand: mtk: Support MT7622 NAND flash controller.")
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
---
drivers/mtd/nand/raw/mtk_ecc.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/raw/mtk_ecc.c b/drivers/mtd/nand/raw/mtk_ecc.c
index e7df3dac705e..49ab3448b9b1 100644
--- a/drivers/mtd/nand/raw/mtk_ecc.c
+++ b/drivers/mtd/nand/raw/mtk_ecc.c
@@ -43,6 +43,7 @@
struct mtk_ecc_caps {
u32 err_mask;
+ u32 err_shift;
const u8 *ecc_strength;
const u32 *ecc_regs;
u8 num_ecc_strength;
@@ -76,7 +77,7 @@ static const u8 ecc_strength_mt2712[] = {
};
static const u8 ecc_strength_mt7622[] = {
- 4, 6, 8, 10, 12, 14, 16
+ 4, 6, 8, 10, 12
};
enum mtk_ecc_regs {
@@ -221,7 +222,7 @@ void mtk_ecc_get_stats(struct mtk_ecc *ecc, struct mtk_ecc_stats *stats,
for (i = 0; i < sectors; i++) {
offset = (i >> 2) << 2;
err = readl(ecc->regs + ECC_DECENUM0 + offset);
- err = err >> ((i % 4) * 8);
+ err = err >> ((i % 4) * ecc->caps->err_shift);
err &= ecc->caps->err_mask;
if (err == ecc->caps->err_mask) {
/* uncorrectable errors */
@@ -449,6 +450,7 @@ EXPORT_SYMBOL(mtk_ecc_get_parity_bits);
static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = {
.err_mask = 0x3f,
+ .err_shift = 8,
.ecc_strength = ecc_strength_mt2701,
.ecc_regs = mt2701_ecc_regs,
.num_ecc_strength = 20,
@@ -459,6 +461,7 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt2701 = {
static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = {
.err_mask = 0x7f,
+ .err_shift = 8,
.ecc_strength = ecc_strength_mt2712,
.ecc_regs = mt2712_ecc_regs,
.num_ecc_strength = 23,
@@ -468,10 +471,11 @@ static const struct mtk_ecc_caps mtk_ecc_caps_mt2712 = {
};
static const struct mtk_ecc_caps mtk_ecc_caps_mt7622 = {
- .err_mask = 0x3f,
+ .err_mask = 0x1f,
+ .err_shift = 5,
.ecc_strength = ecc_strength_mt7622,
.ecc_regs = mt7622_ecc_regs,
- .num_ecc_strength = 7,
+ .num_ecc_strength = 5,
.ecc_mode_shift = 4,
.parity_bits = 13,
.pg_irq_sel = 0,
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: rawnand: fix ecc parameters for mt7622
2022-04-02 16:03 [PATCH] mtd: rawnand: fix ecc parameters for mt7622 Chuanhong Guo
@ 2022-04-04 8:43 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2022-04-04 8:43 UTC (permalink / raw)
To: Chuanhong Guo, linux-mtd
Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
Matthias Brugger, Alexandre Belloni, Pratyush Yadav,
Paul Cercueil, Yu Kuai, Cai Huoqing, RogerCC Lin,
Boris Brezillon, moderated list:ARM/Mediatek SoC support,
moderated list:ARM/Mediatek SoC support, open list
On Sat, 2022-04-02 at 16:03:13 UTC, Chuanhong Guo wrote:
> 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: 98dea8d71931 ("mtd: nand: mtk: Support MT7622 NAND flash controller.")
> Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.
Miquel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-04 8:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-02 16:03 [PATCH] mtd: rawnand: fix ecc parameters for mt7622 Chuanhong Guo
2022-04-04 8:43 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).