From patchwork Fri Jul 22 16:10:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2242 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D6B153F047 for ; Fri, 22 Jul 2022 18:11:24 +0200 (CEST) Received: by mail-ej1-f71.google.com with SMTP id hs16-20020a1709073e9000b0072b73a28465sf2107620ejc.17 for ; Fri, 22 Jul 2022 09:11:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658506284; cv=pass; d=google.com; s=arc-20160816; b=S1RjUvF6l1bI6/3LGhEwIDEBLM0UwFd+KDiqT2aaYvNT9uq13h7VDF5n5Qg5673y0/ 0EV7j1YpNRoSk9jeAzJWI3PdWSozEQcH5KgrAs5zPLm5bt0/aCBpwhVldhQXWZ5dIncC j6R1kUQm/Im69whQMrtFKSYoAG9UU14EB/ZzQMFD5HaxiPT9xEmyE0b8LE+lBYcC+Dry GVBPv8DDfETS7vwtg3LcscBE0lW/uCni31ESIb0P8kmxj8I8GVWq2fC4UTZTu2PhWfrc yVyeoaBGbKgs7i3KE/T2KRq4iM3G7CQtxtuiLhVe0BDQ3S+/fFedSGAwy6hw3Zld9exH gElw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=2C1VJm1l3z6r5eKWqbtgvXuNzqZfkGTOfeTpMgLc7cE=; b=q6VWa8eYdWEoLnC7rwtgivKvNlJGv+iY7wqmrPEgZTCdsQ7re//xA3g29OKsg4GS0H SlNVut1e4QXVMnCRwrLQNqI6g9K5+dcEW4gxTJ73s2L78cIeJRTGO/u1wgmbMcZ0Kzjo yD4HliU2huvTAT6/fai2ER41+Gtpf/Lfd+uJmoE48dD3Kr4xk8KhG8xoLTcPOzB3roDq tJB2jXzIyaW068RLA6PgmVeqcFYUShPEyZzBSYf/ZAFxNc7NajVItKE0GMvyQeJaMCR6 mVfg4hiIPD66vwxmeqrRsdN9pRh3yP89HRX6PdlpeEGYJYf+qA9cPL8XpSh/TzsNyDHp Pr6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MKrb+6jm; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com 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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=2C1VJm1l3z6r5eKWqbtgvXuNzqZfkGTOfeTpMgLc7cE=; b=aNefI1GwZUGfGrbI0rerLmoXtsk55huzfyYDtOkEGyeZsjJfC0dOG3GXuJXUGw8eRW BCwIzmXwKM3oBDbjSJ2LReeQDXADfY/P62xfATUlFhraR6kRfrp0/Iq7wdNgEMUj/BBE 6bVv+t5faKdCRrSUaJxIFsl0uIiAbjcRQ5p4o= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=2C1VJm1l3z6r5eKWqbtgvXuNzqZfkGTOfeTpMgLc7cE=; b=K7J9ZriqdlggSDaHsvGjpEGyDtwEM8dxPyx3zYiwcSTJgQUFsWsFrwGtUMIyNtW/zw 8orXSetgIk4LmF0c1RFDHgja1GR+y6FQ9680qMMPDi9cnsWbFAhzkVrDVsMdXb+2pzK7 ZTXRqWjx2hkEqRhWH1hV+F4qBRe8Nr4856KjkhQ3eFu/HBVrktNUaSqiMSCDbsbphGt2 fUB0ucXqzP/jOPEoku41zKrEdg9ysy3idOMf0DoAvgux7fKQmX3cQsGqwnlTdxDDE7tJ Lr6ZzAYpSfZmYADvESZ/ElEIunZFkRAD0RubvUbnfXxNprE0JrMy9VDDJ1jffOjrD2y7 ZfSw== X-Gm-Message-State: AJIora8lpGQsuzCi5/AOzLdW9mQQdUKZvaY2CxhsGuVve7uaSiRHUGCR hFENxMAfunTfrqnNNhicPhGFL6hx X-Google-Smtp-Source: AGRyM1tfJMerzyd9jiYWSJMFtSWmw8TGmmS1poFoeBKt4Q6j0SidMXLThAN0vJS8C6GZS+vo+C2eXw== X-Received: by 2002:a17:906:9b93:b0:72b:8fad:6cf8 with SMTP id dd19-20020a1709069b9300b0072b8fad6cf8mr470407ejc.415.1658506284713; Fri, 22 Jul 2022 09:11:24 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:f9c4:b0:72f:b55a:8f8c with SMTP id lj4-20020a170906f9c400b0072fb55a8f8cls60030ejb.6.-pod-prod-gmail; Fri, 22 Jul 2022 09:11:23 -0700 (PDT) X-Received: by 2002:a17:907:2cef:b0:72b:5b3e:3d7a with SMTP id hz15-20020a1709072cef00b0072b5b3e3d7amr474587ejc.293.1658506283576; Fri, 22 Jul 2022 09:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658506283; cv=none; d=google.com; s=arc-20160816; b=oZjK3cSFkEDjBNEyHN70FhNDf2KU5su2XNNeigtx977E/MayO47QROd0c3dh+H7D8+ +S0L9fPLfg1Xwh81KtDOS9Mu+D0qAWRZ4UX809QVsvSoY0SuNP9Mlsv6Gh1uz4iKWM5g +/CmjGG9G0j+l8wfkddmpMZCxAmUI4j2r0CvoVlZc/zuHaYWNItZXV3qwADzmciOYep/ NwRAIXMJ2EKElqPi9xDElL6d889CLPVFUoFMOisiWwtc/WJP47eAOzCn0xSlxb7xW5M5 B4b/drHfPp1TkdMcHtiv8eiTPZnahxtkgseBxQyGSlhydIZ2vUAf6L74eTAAuF4fP9a3 5/sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=KXBxjCZi8CVVOTeycIO4txADLeL/+95AM1OP9PR9ktQ=; b=omCncQcJr5yKEGiZUV6x+R1ZYCGb0Ej1tAoclgAw2/NEai7hHHWLbh0RH5HTodrZ95 yNOAD4i0EQO8wBgGsF6kqY7LDJjqlM886dg6c3ZSKgqYPYMIMGwWN8GLts4bI7Fbotys ACPrL8G54xfRcbwrrJnVzLtd5UJoiuyJ0ObyEUblVTHMM5ZpOEneqYbxSdAiRqfgZYEX 7ZdT9ya+yQY/mXh0y118AhycIEwQzZS2cSJkIcxUMCRhtY50tFStlYAT8tiOyQ1eR0pG vSgdtonnpbjWGP+ErQGpSSzqGNOokmWy/ExkdkEREuevAuEL8zAwgw58KcXJwcLKzw/k etTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MKrb+6jm; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id n18-20020a17090695d200b0072ae925a14esor2164152ejy.52.2022.07.22.09.11.23 for (Google Transport Security); Fri, 22 Jul 2022 09:11:23 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; 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 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=MKrb+6jm; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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)