From patchwork Wed Apr 11 03:41:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xiaolei li X-Patchwork-Id: 897018 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mediatek.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PTxn2TLy"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40LVJw0bb1z9s1p for ; Wed, 11 Apr 2018 13:44:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DTEVYQmLA3/mN7rdn7aqXGivhniurKKPtU/bxV7JDxk=; b=PTxn2TLyaBPioK bu+xUhjhiyR+yVW0LEMAtqCYZK0SqrKqomOnKAhmDendpMdZPddbYPotnpfhJXRLzDmZTWoXtvEms t+K+Sw7MYQeEeoVTVmUKwwho907NGCaKhZ+Rx7D0/QW/3/Xu5WwX56+b1bVd/lYAyUYCW+SFHSQ9h 0S9Lxm/7/vsNo/a1AFCJCxsLt4XgED5JcM8eCCcB1iODVH1QZb/MqgVUrVvKB15XtLcykN+bqw0tv RgwpMiCwDkQxmhXkLFsC2ZXPRCCFIuKS2EstQnWqQKYVxRjlK7yVgUlgWVFpSD+WAE6KaEOvAZ47M 9wkffDzRPPnFpzrECOkQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f66g1-0002rS-6Q; Wed, 11 Apr 2018 03:44:05 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f66eV-0001uv-8b; Wed, 11 Apr 2018 03:42:33 +0000 X-UUID: f6b9e7109777475b80cb1d16fa8e376d-20180411 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 55048755; Wed, 11 Apr 2018 11:42:16 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 11 Apr 2018 11:42:14 +0800 Received: from mtkslt306.mediatek.inc (10.21.14.136) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 11 Apr 2018 11:42:14 +0800 From: Xiaolei Li To: , Subject: [PATCH 7/8] mtd: rawnand: mtk: Introduce mtk_ecc_get_strength_num(), mtk_ecc_get_strength() Date: Wed, 11 Apr 2018 11:41:57 +0800 Message-ID: <1523418118-57686-8-git-send-email-xiaolei.li@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1523418118-57686-1-git-send-email-xiaolei.li@mediatek.com> References: <1523418118-57686-1-git-send-email-xiaolei.li@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180410_204231_451490_B270C943 X-CRM114-Status: UNSURE ( 7.71 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.3 (+) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (1.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mediatek@lists.infradead.org, xiaolei.li@mediatek.com, linux-mtd@lists.infradead.org, srv_heupstream@mediatek.com Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Introduce mtk_ecc_get_strength_num(), mtk_ecc_get_strength() functions, and prepare to support struct nand_ecc_caps. Signed-off-by: Xiaolei Li --- drivers/mtd/nand/raw/mtk_ecc.c | 24 ++++++++++++++++++------ drivers/mtd/nand/raw/mtk_ecc.h | 2 ++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nand/raw/mtk_ecc.c b/drivers/mtd/nand/raw/mtk_ecc.c index 717d553..71390e7 100644 --- a/drivers/mtd/nand/raw/mtk_ecc.c +++ b/drivers/mtd/nand/raw/mtk_ecc.c @@ -51,9 +51,9 @@ struct mtk_ecc_caps { u32 err_mask; - const u8 *ecc_strength; + const int *ecc_strength; const u32 *ecc_regs; - u8 num_ecc_strength; + int num_ecc_strength; u8 ecc_mode_shift; u32 parity_bits; int pg_irq_sel; @@ -73,17 +73,17 @@ struct mtk_ecc { }; /* ecc strength that each IP supports */ -static const u8 ecc_strength_mt2701[] = { +static const int ecc_strength_mt2701[] = { 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60 }; -static const u8 ecc_strength_mt2712[] = { +static const int ecc_strength_mt2712[] = { 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 68, 72, 80 }; -static const u8 ecc_strength_mt7622[] = { +static const int ecc_strength_mt7622[] = { 4, 6, 8, 10, 12, 14, 16 }; @@ -428,7 +428,7 @@ int mtk_ecc_encode(struct mtk_ecc *ecc, struct mtk_ecc_config *config, void mtk_ecc_adjust_strength(struct mtk_ecc *ecc, u32 *p) { - const u8 *ecc_strength = ecc->caps->ecc_strength; + const int *ecc_strength = ecc->caps->ecc_strength; int i; for (i = 0; i < ecc->caps->num_ecc_strength; i++) { @@ -451,6 +451,18 @@ unsigned int mtk_ecc_get_parity_bits(struct mtk_ecc *ecc) } EXPORT_SYMBOL(mtk_ecc_get_parity_bits); +int mtk_ecc_get_strength_num(struct mtk_ecc *ecc) +{ + return ecc->caps->num_ecc_strength; +} +EXPORT_SYMBOL(mtk_ecc_get_strength_num); + +const int *mtk_ecc_get_strength(struct mtk_ecc *ecc) +{ + return ecc->caps->ecc_strength; +} +EXPORT_SYMBOL(mtk_ecc_get_strength); + int mtk_ecc_calc_parity_bytes(struct mtk_ecc *ecc, int ecc_strength) { return DIV_ROUND_UP(ecc->caps->parity_bits * ecc_strength, 8); diff --git a/drivers/mtd/nand/raw/mtk_ecc.h b/drivers/mtd/nand/raw/mtk_ecc.h index c1546f9..5687864 100644 --- a/drivers/mtd/nand/raw/mtk_ecc.h +++ b/drivers/mtd/nand/raw/mtk_ecc.h @@ -42,6 +42,8 @@ struct mtk_ecc_config { void mtk_ecc_disable(struct mtk_ecc *); void mtk_ecc_adjust_strength(struct mtk_ecc *ecc, u32 *p); unsigned int mtk_ecc_get_parity_bits(struct mtk_ecc *ecc); +int mtk_ecc_get_strength_num(struct mtk_ecc *ecc); +const int *mtk_ecc_get_strength(struct mtk_ecc *ecc); int mtk_ecc_calc_parity_bytes(struct mtk_ecc *ecc, int ecc_strength); struct mtk_ecc *of_mtk_ecc_get(struct device_node *);