| Message ID | 20220727093748.1415135-5-michael@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-amarula+bncBCXK73FY3AFRB54OQSLQMGQEG4GDXNY@amarulasolutions.com> X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B19E53F1F7 for <linux-amarula@patchwork.amarulasolutions.com>; Wed, 27 Jul 2022 11:37:59 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id v9-20020a056402348900b0043bcd680e50sf8995060edc.18 for <linux-amarula@patchwork.amarulasolutions.com>; Wed, 27 Jul 2022 02:37:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1658914679; cv=pass; d=google.com; s=arc-20160816; b=TxWxd12584tpwxpWQpqn1bXAPzi+DcSAabM71qGu26XIN8k71+ZSmRFtztqH6aU6WL qcH+9xRxBMAHi2LpxRdfM4btahTTR0wc3di4xP7+CpbO5WnCPiHixbq14aI1Eao3i+qn zEgmJ0hx+D5qWeoxYpkepg77vTH6gNG1WyLi15tnNscZur0uUhjGKEtcnL1nCUaJ3yU0 aEut0Jlk3sqMyKh8OJd/m6MUSm7kU0/uMrxnPaiKBXo2yvsx7oq9F5HBj6A4sl70D+Ou y5l+GcVgCVjLZLzYXy+IXQ4jPoVuWqJhF6w9lfFN55Cfyie9ue0+/P8TIdU6+/aB3I1W PrHw== 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:to:from:dkim-signature; bh=5ddosn4/bJZT7jBt2EfL5ixz/9xuydVCf9J/kAMK6ac=; b=ji06vOS0ECxn8Pe+elq676KCKSHbDgVzbo1Y5N75tNsoT3oJrL2do26EfT4N1OQm9b rOyVtnA2m7j/lJaT4P0+8Fzngl5yQEwgGMkWH3jB1bSf4HZJJtVEMy/Dy0jJJgATKzyk X7B07TuYd3DMVuWkcvNaDmJkrpNBzOXf+74J58meuv1z67oFtVec+V1Y5rTFWDuLIIvh /A6OZpzVZK62AgzxzG9oiP65t2yJ82R/9WaQxmXJGN+gzo4prBWsz9dAcSrx4WD0FGcH C1SI6duFTyAi+SbI+Op83/7ofWMiQBgPatZJgdXlZgEqqX4WUHF25d3OihIpUdhPy0uh DOnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nMrQ2n5R; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@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: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=5ddosn4/bJZT7jBt2EfL5ixz/9xuydVCf9J/kAMK6ac=; b=e6g75m9Cpin6IFBvYcLt3seelIlzB/5EA1sba8ZKGp1MZysns2u2PmcTf5kfvDfe41 Cpz9zAbp78YV85uwcEDRJyD+7U+j5wa0zEbmNFe6d6mwDQZeSAGywwD91SdPn98ZUoum 4pNgRUwoHNPIIwVDPdj4ZJQkG4ZQn0Kj6RP4o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to: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=5ddosn4/bJZT7jBt2EfL5ixz/9xuydVCf9J/kAMK6ac=; b=pbl0j2Yx0Z0B3dUw7JdJLtICn+Q52Lxn8kMSarXBe2OvRxFlR/T63luHncVHCljzn6 mAcr0RgWZpGtKMbQTxzrEw+bg1D5BTJ4/7tRoMjFeawCR4xlXFOUe431zDWZG/lccFAr jMXqTBi54uN/5gw7NDzL5MNJbKNJJ4okWzfbBxUbiOBEBmLzqD+FvFQ02hIs45nJnMPW FmeGQ6u8Ns1u0rM0Giqxaragf36xXw0NQPsDSSl1+RxP7pEjXOh2jcMdXswJJ94HkYh3 kTZKBhU9Pddz/A2c8OzGWRSVTS18xXQXdCwAZ7GrmG6WGdMcdIgyuFc+xktSF+Fr3/9z lcCQ== X-Gm-Message-State: AJIora+3fWnFdpeHFU6kTUglZ3cGaYXfsudpl1mWUN397gJgeiVAf0yC D+OhSlJBuzNfWcTOb80T2JdrzagP X-Google-Smtp-Source: AGRyM1tcUvWO3vnRCNR5zrSBpLsvTFWuYD1GN7AeRod5E3EWW0Lscr3XZZJ99IaK0VDYSXCVeO3iHg== X-Received: by 2002:a17:907:2848:b0:72b:5ba5:1db5 with SMTP id el8-20020a170907284800b0072b5ba51db5mr17543097ejc.703.1658914679549; Wed, 27 Jul 2022 02:37:59 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:680f:b0:72b:564b:c25b with SMTP id k15-20020a170906680f00b0072b564bc25bls1900897ejr.7.-pod-prod-gmail; Wed, 27 Jul 2022 02:37:58 -0700 (PDT) X-Received: by 2002:a17:907:2d26:b0:72f:d05:f530 with SMTP id gs38-20020a1709072d2600b0072f0d05f530mr16887394ejc.284.1658914678150; Wed, 27 Jul 2022 02:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658914678; cv=none; d=google.com; s=arc-20160816; b=wp2hgw6cYNbtpE2gqG+SAoOJUhaT/6yMQ7ZsdPjHYRIkZbuWqlY7SJaL0K0zqQNwt4 GmgKMgY47c6xcnaIXaoLlMqJoNpkDsI4frh2uw24km4LuJQR/Tft+XHg9NE9bdisjq8+ tWM3ibNmUG8XEBCiGB8/NdLbtmlWL/PlIBpsNd8WDa2t4rJHPX12kz2mXhavytCtaNRr ShknzE8EZn4ZdRTfY2E6h4Lk80gfIhiCjx7Jj0Gts2ZA3Ps1NavLsiNsmzb1t+JY5KxB uDQPRi4Ik9pnkXKvDZfRHM1V4BuX/YtzZW4m3BwWfcrFHUNGDUf7TEG5+xjr9hiKyWTH QuRA== 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:to:from:dkim-signature; bh=+Kmdd9fm+cOxM+5ZJRvmWU6Fbc3fNB7QutxwJjisqyQ=; b=ahrMPJ8TWOuVmBbfVQyMm0mLe0Z0EhBxkGnQWPSHuAkJhxJN1FE+Qx1HT8t4TVZFKD 9TJH3zCRDgFT3MjkRy+XMU6+4g8YiZsavyZwgvdwL7Mc6LrhKQmZ/ju8tXG6mH+Be+P6 FGXjfI8my/IyBA37TN6o24oLFrAaSFcajAiiPCbcMpyrndLRbzValJwW/xxAASQu1dC4 L6qcMUxyu7fUsKhzr6XZW6NQ3yepOigdBjXZXUjTS5kZjDxHkzXTi+AaYo3WxR/MOORQ JvpIKA4sgyuSIvS5FabLfwK8XQSqgkFTiICfRRfjrSew6Im4pYrh2iy7Hw+fYzeg4Sbb zJCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nMrQ2n5R; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@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 c2-20020a50d642000000b0043cbf85a224sor400559edj.18.2022.07.27.02.37.58 for <linux-amarula@amarulasolutions.com> (Google Transport Security); Wed, 27 Jul 2022 02:37:58 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:5516:b0:43a:42f9:24d6 with SMTP id fi22-20020a056402551600b0043a42f924d6mr10505093edb.204.1658914677823; Wed, 27 Jul 2022 02:37:57 -0700 (PDT) Received: from panicking.amarulasolutions.com (mob-37-181-33-55.net.vodafone.it. [37.181.33.55]) by smtp.gmail.com with ESMTPSA id q22-20020a17090676d600b006fece722508sm7317678ejn.135.2022.07.27.02.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 02:37:57 -0700 (PDT) From: Michael Trimarchi <michael@amarulasolutions.com> To: dario.binacchi@amarulasolutions.com, Tommaso Merciai <tommaso.merciai@amarulasolutions.com>, linux-amarula@amarulasolutions.com Subject: [PATCH 4/7] mtd: nand: samsung: Retrieve ECC requirements from extended Date: Wed, 27 Jul 2022 11:37:45 +0200 Message-Id: <20220727093748.1415135-5-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220727093748.1415135-1-michael@amarulasolutions.com> References: <20220727093748.1415135-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nMrQ2n5R; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@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: <linux-amarula.amarulasolutions.com> X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>, <mailto:linux-amarula@amarulasolutions.com> List-Help: <https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>, <mailto:linux-amarula+help@amarulasolutions.com> List-Archive: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/> List-Unsubscribe: <mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>, <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe> |
| Series |
NAND new improvements
|
|
Commit Message
Michael Trimarchi
July 27, 2022, 9:37 a.m. UTC
Upstream linux commit 8fc82d456e40a0.
On some nand controllers with hw-ecc the controller code wants to know
the ecc strength and size and having these as 0, 0 is not accepted.
Specifying these in devicetree is possible but undesirable as the nand
may be different in different production runs of the same board, so it
is better to get this info from the nand id where possible.
This commit adds code to read the ecc strength and size from the nand
for Samsung extended-id nands. This code is based on the info for the 5th
id byte in the datasheets for the following Samsung nands: K9GAG08U0E,
K9GAG08U0F, K9GAG08X0D, K9GBG08U0A, K9GBG08U0B. These all use these bits
in the exact same way.
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
drivers/mtd/nand/raw/nand_samsung.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
Comments
Hi Michael, On Wed, Jul 27, 2022 at 11:37 AM Michael Trimarchi <michael@amarulasolutions.com> wrote: > > Upstream linux commit 8fc82d456e40a0. > > On some nand controllers with hw-ecc the controller code wants to know > the ecc strength and size and having these as 0, 0 is not accepted. > > Specifying these in devicetree is possible but undesirable as the nand > may be different in different production runs of the same board, so it > is better to get this info from the nand id where possible. > > This commit adds code to read the ecc strength and size from the nand > for Samsung extended-id nands. This code is based on the info for the 5th > id byte in the datasheets for the following Samsung nands: K9GAG08U0E, > K9GAG08U0F, K9GAG08X0D, K9GBG08U0A, K9GBG08U0B. These all use these bits > in the exact same way. > > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> > --- > drivers/mtd/nand/raw/nand_samsung.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/mtd/nand/raw/nand_samsung.c b/drivers/mtd/nand/raw/nand_samsung.c > index 0ab8062193..36ef48e5ec 100644 > --- a/drivers/mtd/nand/raw/nand_samsung.c > +++ b/drivers/mtd/nand/raw/nand_samsung.c > @@ -64,6 +64,26 @@ static void samsung_nand_decode_id(struct nand_chip *chip) > extid >>= 2; > mtd->erasesize = (128 * 1024) << > (((extid >> 1) & 0x04) | (extid & 0x03)); > + > + /* Extract ECC requirements from 5th id byte*/ > + extid = (chip->id.data[4] >> 4) & 0x07; > + if (extid < 5) { > + chip->ecc_step_ds = 512; > + chip->ecc_strength_ds = 1 << extid; > + } else { > + chip->ecc_step_ds = 1024; > + switch (extid) { > + case 5: > + chip->ecc_strength_ds = 24; > + break; > + case 6: > + chip->ecc_strength_ds = 40; > + break; > + case 7: > + chip->ecc_strength_ds = 60; > + break; > + } > + } > } else { > nand_decode_ext_id(chip); > } > -- > 2.34.1 > looks good to me. Dario
On Wed, Jul 27, 2022 at 11:37:45AM +0200, Michael Trimarchi wrote: > Upstream linux commit 8fc82d456e40a0. > > On some nand controllers with hw-ecc the controller code wants to know > the ecc strength and size and having these as 0, 0 is not accepted. > > Specifying these in devicetree is possible but undesirable as the nand > may be different in different production runs of the same board, so it > is better to get this info from the nand id where possible. > > This commit adds code to read the ecc strength and size from the nand > for Samsung extended-id nands. This code is based on the info for the 5th > id byte in the datasheets for the following Samsung nands: K9GAG08U0E, > K9GAG08U0F, K9GAG08X0D, K9GBG08U0A, K9GBG08U0B. These all use these bits > in the exact same way. > > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> > --- > drivers/mtd/nand/raw/nand_samsung.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/mtd/nand/raw/nand_samsung.c b/drivers/mtd/nand/raw/nand_samsung.c > index 0ab8062193..36ef48e5ec 100644 > --- a/drivers/mtd/nand/raw/nand_samsung.c > +++ b/drivers/mtd/nand/raw/nand_samsung.c > @@ -64,6 +64,26 @@ static void samsung_nand_decode_id(struct nand_chip *chip) > extid >>= 2; > mtd->erasesize = (128 * 1024) << > (((extid >> 1) & 0x04) | (extid & 0x03)); > + > + /* Extract ECC requirements from 5th id byte*/ > + extid = (chip->id.data[4] >> 4) & 0x07; > + if (extid < 5) { Just for curiosity, 5 is for? Maybe is better to use a define and avoid magic number? > + chip->ecc_step_ds = 512; > + chip->ecc_strength_ds = 1 << extid; > + } else { > + chip->ecc_step_ds = 1024; > + switch (extid) { > + case 5: > + chip->ecc_strength_ds = 24; > + break; > + case 6: > + chip->ecc_strength_ds = 40; > + break; > + case 7: > + chip->ecc_strength_ds = 60; > + break; > + } > + } > } else { > nand_decode_ext_id(chip); > } > -- > 2.34.1 >
On Wed, Jul 27, 2022 at 11:37:45AM +0200, Michael Trimarchi wrote: > Upstream linux commit 8fc82d456e40a0. > > On some nand controllers with hw-ecc the controller code wants to know > the ecc strength and size and having these as 0, 0 is not accepted. > > Specifying these in devicetree is possible but undesirable as the nand > may be different in different production runs of the same board, so it > is better to get this info from the nand id where possible. > > This commit adds code to read the ecc strength and size from the nand > for Samsung extended-id nands. This code is based on the info for the 5th > id byte in the datasheets for the following Samsung nands: K9GAG08U0E, > K9GAG08U0F, K9GAG08X0D, K9GBG08U0A, K9GBG08U0B. These all use these bits > in the exact same way. > > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> > --- > drivers/mtd/nand/raw/nand_samsung.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/mtd/nand/raw/nand_samsung.c b/drivers/mtd/nand/raw/nand_samsung.c > index 0ab8062193..36ef48e5ec 100644 > --- a/drivers/mtd/nand/raw/nand_samsung.c > +++ b/drivers/mtd/nand/raw/nand_samsung.c > @@ -64,6 +64,26 @@ static void samsung_nand_decode_id(struct nand_chip *chip) > extid >>= 2; > mtd->erasesize = (128 * 1024) << > (((extid >> 1) & 0x04) | (extid & 0x03)); > + > + /* Extract ECC requirements from 5th id byte*/ > + extid = (chip->id.data[4] >> 4) & 0x07; > + if (extid < 5) { > + chip->ecc_step_ds = 512; > + chip->ecc_strength_ds = 1 << extid; > + } else { > + chip->ecc_step_ds = 1024; > + switch (extid) { > + case 5: > + chip->ecc_strength_ds = 24; > + break; > + case 6: > + chip->ecc_strength_ds = 40; > + break; > + case 7: > + chip->ecc_strength_ds = 60; > + break; > + } > + } > } else { > nand_decode_ext_id(chip); > } > -- > 2.34.1 > My bad delete my last msg. I see the comment is clear :) look's good
diff --git a/drivers/mtd/nand/raw/nand_samsung.c b/drivers/mtd/nand/raw/nand_samsung.c index 0ab8062193..36ef48e5ec 100644 --- a/drivers/mtd/nand/raw/nand_samsung.c +++ b/drivers/mtd/nand/raw/nand_samsung.c @@ -64,6 +64,26 @@ static void samsung_nand_decode_id(struct nand_chip *chip) extid >>= 2; mtd->erasesize = (128 * 1024) << (((extid >> 1) & 0x04) | (extid & 0x03)); + + /* Extract ECC requirements from 5th id byte*/ + extid = (chip->id.data[4] >> 4) & 0x07; + if (extid < 5) { + chip->ecc_step_ds = 512; + chip->ecc_strength_ds = 1 << extid; + } else { + chip->ecc_step_ds = 1024; + switch (extid) { + case 5: + chip->ecc_strength_ds = 24; + break; + case 6: + chip->ecc_strength_ds = 40; + break; + case 7: + chip->ecc_strength_ds = 60; + break; + } + } } else { nand_decode_ext_id(chip); }