Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1937123iob; Thu, 5 May 2022 11:16:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyagH622A4kIUngmH0G8tD0oU4+ZkFLarstRDfyzZkuirQYFKMf8yOWuVL2AcULjhz8BM3h X-Received: by 2002:a17:90b:245:b0:1dc:1597:20e with SMTP id fz5-20020a17090b024500b001dc1597020emr7596850pjb.151.1651774580248; Thu, 05 May 2022 11:16:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651774580; cv=none; d=google.com; s=arc-20160816; b=B8p5pyrqO6qVDLnWiIbMNEhLf9spVNHQ8rgFUmsG8EtsNme8x+XrfYkuj48L5vD0YW uEeRKeeRUgCao3XCyrVqU+KFi7r1UvSQEULJnY2YyFTjsa4h/VmjVj5mWCpJZ6AbhHYE U2kf+GjL8IdA9miQ1GkuiF+P6MmR0fPMf61xjZ1YCdTXAtpCqsAFr61ZV80WIOseRMiO isC5IsyDeBWeHG7/fZ4LPAmoLcQs5zMlGwNqs/TN2XCowHA+dGr8ivmEYEqPrDLF3mOe kgNpfdXx/LP03ruZXt39faLacoW7veFc9Ox/lMKx69p8gbbWPkaGEozigD/Bz08oyUb5 BJiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ORP8BHHaZ2KEFov1+237akreGWdl15ZK3UK3VWjO5tg=; b=JzTOsDEMaFfe41GSPFfwk+hnTtLHlN6AhytMrW18WIJ3vI7oAf80vuYl6tG5N3uc8R Tv9sILYI4pjwpcZk1h1dLgCS8pyXRfXUHByUi4pCWjNbr2aZ3rvKpIBIniScYAkc2SXS wE1XJ4zI9DvGH/v3tXtVMlFG3fsHl7raGuMJcOVnqGJArOf08YEoiWkukuCP7D5BrzU0 tWwf4lMCSt/3612j7sqqTgLoY7u24WFyAPAfBZ52ZMxp3u7SIA6seBmSUJWmbxLGpJB4 hVUtVXyorAR2TsEUODvi0L5PuUdv2ZNujUndG5nyjJ4in6IBwQc21rjwqe7JyC1INK+t beNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W+fflOmM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k14-20020aa7820e000000b0050a99acc9ecsi2141099pfi.45.2022.05.05.11.16.00; Thu, 05 May 2022 11:16:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W+fflOmM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354590AbiEDQ6x (ORCPT + 99 others); Wed, 4 May 2022 12:58:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353772AbiEDQwj (ORCPT ); Wed, 4 May 2022 12:52:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5DBB47573; Wed, 4 May 2022 09:48:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 556ECB82553; Wed, 4 May 2022 16:48:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD827C385A5; Wed, 4 May 2022 16:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651682926; bh=Q9CsuP3nha7SVOaCVYQQPn34IWlxKcJIUkjE8vjF9hU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W+fflOmMkTeFH4gHahKgNMOFzLGqxaED9gmZhmRfMRccUYTFhIaEjWWrxvkeCl6V0 +0Elfl9eqTU7xQKuKzSo0pO0R10llkQI+pcNWn9msS7/36xa16oJ+m+iRj97srQ/AA csIoh73Rq4+u8OhXwgjIMMXx7pG9ecTCI9cjufcc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuanhong Guo , Miquel Raynal , Sasha Levin Subject: [PATCH 5.4 32/84] mtd: rawnand: fix ecc parameters for mt7622 Date: Wed, 4 May 2022 18:44:13 +0200 Message-Id: <20220504152930.050231211@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504152927.744120418@linuxfoundation.org> References: <20220504152927.744120418@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chuanhong Guo [ Upstream commit 9fe4e0d3cbfe90152137963cc024ecb63db6e8e6 ] 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 Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20220402160315.919094-1-gch981213@gmail.com Signed-off-by: Sasha Levin --- 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 74595b644b7c..57fa7807cd7d 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