Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5ED8C433EF for ; Fri, 8 Jul 2022 14:14:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 26E4684580; Fri, 8 Jul 2022 16:14:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="nWfNVjgN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D165D843A9; Fri, 8 Jul 2022 16:14:44 +0200 (CEST) Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A35CA8451C for ; Fri, 8 Jul 2022 16:14:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@amarulasolutions.com Received: by mail-ej1-x634.google.com with SMTP id d2so38004076ejy.1 for ; Fri, 08 Jul 2022 07:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kmz44/PGwk8ZR5YMjWaKJTxEhx38Jps8/Gm7QuwZCQ4=; b=nWfNVjgN1jj4sT6WpQL7S+CJOFJFOJHZpT9uIu5rs+n0CdYlXh4UWfs9LGzUMQ+dsT n0Gzp9GJkTdMm6xRm4S1x8ATB2Kvn8xvr+Li5jp0zsMma8IEmOQkQTUeh6pPTxTjXD9y RzMiWtvTFqS/nHW8w72QrT+S6zSxDNgFjy1pY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kmz44/PGwk8ZR5YMjWaKJTxEhx38Jps8/Gm7QuwZCQ4=; b=YXaSRRxQfIw3wUIbN7nOOwKEAUecnCXCqzT3w1+ELXlqQXFLgV3Kd/8aGylP6AyBxH uZiGoYlZ0mlP2Gn3hyAmbzvll3+aKnqHtfxxLp1jwbZ5Q6IhMcOWXNVV6DjEh/vi7RoP 0ajERNmYct9xvRlxOs483y4J2tOtwamx3PrDQGZXVIgsA1NbmrMohb0Hohv9Q6buREJ9 fIyhRyVXVC70GdkXOkcNY4qq6VaWVnId69K+VSB/SOl9TInU/ov5btbynkYmr54BwJe9 B4oNomH9Tg1HWCj4OIZy9Q7mzaMwJvQCMKMEtJxjBBtjtiUCbg05zFKdREgYC78T0fAU pXYA== X-Gm-Message-State: AJIora8VYh2J2DX0VxJc9BzA7ukENexjiVkLnycz2Z8VMIu56f4+ibDQ Tbh5R2pqjrztaUGziznDdSLpbQ== X-Google-Smtp-Source: AGRyM1uX2WRxlsURi5lFlRJx4SHtDUcT7T4Uc+Oba/u0x6RZaYCO67gSML6C5gXiPmmYwKaV+6wDsg== X-Received: by 2002:a17:907:72c4:b0:726:9406:f760 with SMTP id du4-20020a17090772c400b007269406f760mr3654764ejc.247.1657289682147; Fri, 08 Jul 2022 07:14:42 -0700 (PDT) Received: from panicking.amarulasolutions.com ([62.18.232.106]) by smtp.gmail.com with ESMTPSA id s3-20020a1709067b8300b0070efa110afcsm20419074ejo.83.2022.07.08.07.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 07:14:41 -0700 (PDT) From: Michael Trimarchi To: linux-amarula@amarulasolutions.com, Dario Binacchi , u-boot@lists.denx.de (open list) Cc: u-boot@lists.denx.de (open list) Subject: [PATCH 1/2] mtd: nand: Fix ecc in mxs_nand_spl onfi mode Date: Fri, 8 Jul 2022 16:14:38 +0200 Message-Id: <20220708141439.164394-1-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean We need to calculate the ecc parameters in a way that are the same in uboot and spl. The parameters are connected to the onfi computation. We need to assign all the value of chip in order to have same ecc strength parameters before calling mxs_nand_set_geometry that calculate the ecc layout /* use the legacy bch setting by default */ if ((!nand_info->use_minimum_ecc && mtd->oobsize < 1024) || !(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0)) { dev_dbg(mtd->dev, "use legacy bch geometry\n"); err = mxs_nand_legacy_calc_ecc_layout(geo, mtd); if (!err) return 0; } Signed-off-by: Michael Trimarchi --- drivers/mtd/nand/raw/mxs_nand_spl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mtd/nand/raw/mxs_nand_spl.c b/drivers/mtd/nand/raw/mxs_nand_spl.c index 3daacbb330..683071c1cb 100644 --- a/drivers/mtd/nand/raw/mxs_nand_spl.c +++ b/drivers/mtd/nand/raw/mxs_nand_spl.c @@ -139,6 +139,10 @@ static int mxs_flash_onfi_ident(struct mtd_info *mtd) mtd->writesize = le32_to_cpu(p->byte_per_page); mtd->erasesize = le32_to_cpu(p->pages_per_block) * mtd->writesize; mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page); + if (p->ecc_bits != 0xff) { + chip->ecc_strength_ds = p->ecc_bits; + chip->ecc_step_ds = 512; + } chip->chipsize = le32_to_cpu(p->blocks_per_lun); chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count; /* Calculate the address shift from the page size */ @@ -152,6 +156,8 @@ static int mxs_flash_onfi_ident(struct mtd_info *mtd) debug("writesize=%d (>>%d)\n", mtd->writesize, chip->page_shift); debug("oobsize=%d\n", mtd->oobsize); debug("chipsize=%lld\n", chip->chipsize); + debug("ecc_strength_ds=%d\n", chip->ecc_strength_ds); + debug("ecc_step_ds = %d\n", chip->ecc_step_ds); return 0; } -- 2.34.1