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 25D0EC04A68 for ; Thu, 28 Jul 2022 17:18:48 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 213C0841AA; Thu, 28 Jul 2022 19:18:07 +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="kber122+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8F978841DF; Thu, 28 Jul 2022 19:18:01 +0200 (CEST) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (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 4823B83FC2 for ; Thu, 28 Jul 2022 19:17:59 +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-wr1-x42b.google.com with SMTP id l4so3073848wrm.13 for ; Thu, 28 Jul 2022 10:17:59 -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=+Kmdd9fm+cOxM+5ZJRvmWU6Fbc3fNB7QutxwJjisqyQ=; b=kber122+BsslYZJ8nqoUz1pyJy/eAvk3IFushfDc/1lJNyfU9ALh/RxUbiD2KTKz0F lcIUV3fl1DlDsNhdnz5Jtb6o0/8vJ/mn4K6dT4YaNJA9cSDwwzIVjXinbp1PJFVcv+dy XX5bNLL6KVnivgOIpMTuIwF2xH+IOU0/fJChc= 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=+Kmdd9fm+cOxM+5ZJRvmWU6Fbc3fNB7QutxwJjisqyQ=; b=Gs0AdLIAIsjs0d41ZwB3zhSJI0MPzVAyrJiUlAM8uSoUaOxQKCsxQ9pLsr7c03sErp 8P+UhYB5nvY6rnNaOliHA9zzZDte8ctVtR/C4TXVMTNrWfUR8rdnL9VtqQ+OkgGQGNZ5 rw09/AiBTtEfYJBHKdwYm2gn3lwy5AAxQJYIdI2/x1AkGrJshbkGoEiYrukd/4Ap+p5D Aar4PRn170QafJ6qy7g5NqZbaoU2bG1RQbgjBrTVcMGpO1fXt3qsKYTF+d4ktWzIU6Kb c2Mycjmzjc90obcm4UoYIcOHwSQJFgLveZ8fSQ7UauidjTbUvO2SIYkPwHxjckjUdj2x cfeQ== X-Gm-Message-State: AJIora+Jb2HsOsrXSnME9GqpoMnD27pJNKcrv2sy6cY2e65Qsn5aZukx /eXvSDNlSmQuw5/DJJD6YNHiLg== X-Google-Smtp-Source: AGRyM1ujyghnu3IFwh8OjarGiubBGNcF70LVtSr7fbkatuE80x+kO7esEKX2g6lzd5DepEYHZQniEg== X-Received: by 2002:adf:f911:0:b0:21e:c0f6:fd26 with SMTP id b17-20020adff911000000b0021ec0f6fd26mr6870960wrr.361.1659028678724; Thu, 28 Jul 2022 10:17:58 -0700 (PDT) Received: from panicking.amarulasolutions.com ([2.196.208.4]) by smtp.gmail.com with ESMTPSA id h3-20020a5d4fc3000000b0021eba590ad1sm1667850wrw.90.2022.07.28.10.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 10:17:56 -0700 (PDT) From: Michael Trimarchi To: Dario Binacchi , u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Tommaso Merciai Subject: [PATCH 4/5] mtd: nand: samsung: Retrieve ECC requirements from extended Date: Thu, 28 Jul 2022 19:17:42 +0200 Message-Id: <20220728171744.1761739-5-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220728171744.1761739-1-michael@amarulasolutions.com> References: <20220728171744.1761739-1-michael@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 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 --- 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