Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753973AbcKZSOf (ORCPT ); Sat, 26 Nov 2016 13:14:35 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:48148 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753188AbcKZSIV (ORCPT ); Sat, 26 Nov 2016 13:08:21 -0500 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com uAQI6Uf8018512 X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org, Boris Brezillon , Marek Vasut , Brian Norris , Richard Weinberger , David Woodhouse , Cyrille Pitchen Subject: [PATCH 36/39] mtd: nand: denali: allow to use SoC-specific ECC strength Date: Sun, 27 Nov 2016 03:06:22 +0900 Message-Id: <1480183585-592-37-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480183585-592-1-git-send-email-yamada.masahiro@socionext.com> References: <1480183585-592-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2523 Lines: 79 The ecc.strength of this IP is a platform-dependent parameter. I chose {15, 8} as the default to respect the historical reason of this driver, but it should be overridable to use this driver for other SoCs. If necessary, SoCs can provide their own ecc_strength_avail. This must be an array of supported ecc.strength in descending order, terminated by zero. Signed-off-by: Masahiro Yamada --- drivers/mtd/nand/denali.c | 5 ++++- drivers/mtd/nand/denali.h | 1 + drivers/mtd/nand/denali_dt.c | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index f2ed3f8..54c9e0c 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -1373,7 +1373,7 @@ static int denali_set_max_ecc_strength(struct denali_nand_info *denali) int oobsize = mtd->oobsize; int ecc_size = chip->ecc.size; int ecc_steps = mtd->writesize / chip->ecc.size; - const int *ecc_strength = denali_default_ecc_strength; + const int *ecc_strength = denali->ecc_strength_avail; int ecc_bytes; /* carve out the BBM area */ @@ -1625,6 +1625,9 @@ int denali_init(struct denali_nand_info *denali) chip->ecc.size = denali->caps & DENALI_CAPS_ECC_SIZE_1024 ? 1024 : 512; + if (!denali->ecc_strength_avail) + denali->ecc_strength_avail = denali_default_ecc_strength; + ret = denali_set_max_ecc_strength(denali); if (ret) goto failed_req_irq; diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h index 5209625..2892e46 100644 --- a/drivers/mtd/nand/denali.h +++ b/drivers/mtd/nand/denali.h @@ -428,6 +428,7 @@ struct denali_nand_info { u32 devnum; /* represent how many nands connected */ u32 bbtskipbytes; u32 max_banks; + const int *ecc_strength_avail; unsigned int caps; #define DENALI_CAPS_HW_ECC_FIXUP BIT(0) #define DENALI_CAPS_DMA_64BIT BIT(1) diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c index f085626..aa1e032 100644 --- a/drivers/mtd/nand/denali_dt.c +++ b/drivers/mtd/nand/denali_dt.c @@ -30,6 +30,7 @@ struct denali_dt { }; struct denali_dt_data { + const int *ecc_strength_avail; unsigned int caps; }; @@ -54,8 +55,10 @@ static int denali_dt_probe(struct platform_device *pdev) denali = &dt->denali; data = of_device_get_match_data(&pdev->dev); - if (data) + if (data) { + denali->ecc_strength_avail = data->ecc_strength_avail; denali->caps = data->caps; + } denali->caps |= DENALI_CAPS_HW_ECC_FIXUP; -- 2.7.4