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 CDFCFC433EF for ; Fri, 22 Jul 2022 16:12:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B73FC841EF; Fri, 22 Jul 2022 18:11:50 +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="MKrb+6jm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1C7918416D; Fri, 22 Jul 2022 18:11:33 +0200 (CEST) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (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 AA639840CB for ; Fri, 22 Jul 2022 18:11:23 +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=dario.binacchi@amarulasolutions.com Received: by mail-ej1-x632.google.com with SMTP id l23so9390469ejr.5 for ; Fri, 22 Jul 2022 09:11:23 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=KXBxjCZi8CVVOTeycIO4txADLeL/+95AM1OP9PR9ktQ=; b=MKrb+6jmH7M5dpabSNvI52v/mIilbab90kFZ6n3Y5cPEA4/hJU58p2vN8S2mh+pcMR lDzj4VqOhxdSOaB7/GImeol/GSAt3+Uw77M9Pf01SAV6Uzqj1eXWAwgq/gFfJrouXMFp 8T/oMsxdM+UGwPGckl3A+6M9T5d9MEfVsX080= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=KXBxjCZi8CVVOTeycIO4txADLeL/+95AM1OP9PR9ktQ=; b=fKCGa0z5mM1+sxfxRpZi3IOly+oh2wSgddcwQADv8peo2As42SXFXdhbfycXb6b0th ivUFXjV180tOmHzR8pzR2cfM0ll910Gk2lIdjuNrWdRyw2n42InkmRaY/nG9iZ4NIaSw HnzeAc/M4cVEBwbukahxECqjrpDRZjjnyp/1AWv0GE7pZa9/ceXflvINIf8f0sxJgLHm pPzFUR438WdX7jil/QgMzOQh5VuVaIONdNKtaGMd6bq49K1Jl+VKVhH/f5j+d6zrB0xB jGrbk/n55ceRup6ssJwyRk0GTaWv9RVcYTyWqRtTaMT9R6u1Gb38yk9FmKcKEvp2D0fN 0FUQ== X-Gm-Message-State: AJIora+7GTCBk9FqIEnr6FBDztlHK+ge8wPKEYBFuhEh+qoXYSb5zplG 0tUr4TpC0hULVMgPDvzumY4y4gbCpmz6FQ== X-Google-Smtp-Source: AGRyM1vpyPGUxwD4D/lXLBGu1eQQuO5aaR30jQEU7vajU3SAvJBxzDjjLv/5/9NL378w8yEzZIQkbw== X-Received: by 2002:a17:906:4fc3:b0:72e:eab4:d9d7 with SMTP id i3-20020a1709064fc300b0072eeab4d9d7mr463302ejw.599.1658506283171; Fri, 22 Jul 2022 09:11:23 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-87-14-98-67.retail.telecomitalia.it. [87.14.98.67]) by smtp.gmail.com with ESMTPSA id d19-20020a170906305300b006fe8ac6bc69sm2174025ejd.140.2022.07.22.09.11.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:11:22 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Amarula patchwork , michael@amarulasolutions.com, Dario Binacchi Subject: [PATCH v4 13/14] mtd: nand: toshiba: Retrieve ECC requirements from extended ID Date: Fri, 22 Jul 2022 18:10:07 +0200 Message-Id: <20220722161009.2686504-14-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220722161009.2686504-1-dario.binacchi@amarulasolutions.com> References: <20220722161009.2686504-1-dario.binacchi@amarulasolutions.com> 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 From: Michael Trimarchi Upstream linux commit fb3bff5b407e58. This patch enables support to read the ECC strength and size from the NAND flash using Toshiba Memory SLC NAND extended-ID. This patch is based on the information of the 6th ID byte of the Toshiba Memory SLC NAND. Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- (no changes since v3) Changes in v3: - Use commit sha1 with 13 digits. Changes in v2: - Use short-commit form - Remove linux info. Uboot seems that backport without add this extra information. drivers/mtd/nand/raw/nand_toshiba.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_toshiba.c b/drivers/mtd/nand/raw/nand_toshiba.c index f7426fa59f51..99dc44df671a 100644 --- a/drivers/mtd/nand/raw/nand_toshiba.c +++ b/drivers/mtd/nand/raw/nand_toshiba.c @@ -37,6 +37,32 @@ static void toshiba_nand_decode_id(struct nand_chip *chip) (chip->id.data[5] & 0x7) == 0x6 /* 24nm */ && !(chip->id.data[4] & 0x80) /* !BENAND */) mtd->oobsize = 32 * mtd->writesize >> 9; + + /* + * Extract ECC requirements from 6th id byte. + * For Toshiba SLC, ecc requrements are as follows: + * - 43nm: 1 bit ECC for each 512Byte is required. + * - 32nm: 4 bit ECC for each 512Byte is required. + * - 24nm: 8 bit ECC for each 512Byte is required. + */ + if (chip->id.len >= 6 && nand_is_slc(chip)) { + chip->ecc_step_ds = 512; + switch (chip->id.data[5] & 0x7) { + case 0x4: + chip->ecc_strength_ds = 1; + break; + case 0x5: + chip->ecc_strength_ds = 4; + break; + case 0x6: + chip->ecc_strength_ds = 8; + break; + default: + WARN(1, "Could not get ECC info"); + chip->ecc_step_ds = 0; + break; + } + } } static int toshiba_nand_init(struct nand_chip *chip) -- 2.32.0